wip: e2e private-sites capture harness and blog templates
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576(() => { const posts = Array.isArray(window.blogPosts) ? window.blogPosts : [] const postBySlug = new Map(posts.map((post) => [post.slug, post]))
const formatDate = (date) => new Intl.DateTimeFormat('en', { year: 'numeric', month: 'short', day: 'numeric', }).format(new Date(`${date}T12:00:00`))
const metadata = (post) => ` <div class="post-meta"> <time datetime="${post.date}">${formatDate(post.date)}</time> <span aria-hidden="true">·</span> <span>${post.readingTime}</span> ${post.tags?.[0] ? `<span aria-hidden="true">·</span><span>${post.tags[0]}</span>` : ''} </div> `
const postRow = (post) => ` <article class="post-row"> <a class="post-row-content" href="post.html?slug=${encodeURIComponent(post.slug)}"> ${metadata(post)} <h3>${post.title}</h3> <p>${post.description}</p> </a> <a class="read-link" href="post.html?slug=${encodeURIComponent(post.slug)}" aria-label="Read ${post.title}">Read <span aria-hidden="true">↗</span></a> </article> `
const renderPostList = () => { const list = document.querySelector('#post-list') const count = document.querySelector('#post-count') if (!list) return
if (count) count.textContent = `${posts.length} ${posts.length === 1 ? 'post' : 'posts'}`
list.innerHTML = posts.length ? posts.map(postRow).join('') : '<p class="empty-state">No posts yet. Add one in posts.js.</p>' }
const renderPost = () => { const container = document.querySelector('#post') if (!container) return
const slug = new URLSearchParams(window.location.search).get('slug') const post = slug ? postBySlug.get(slug) : undefined
if (!post) { document.title = 'Post not found · Blog' container.innerHTML = ` <div class="empty-state"> <h1>Post not found</h1> <p>That note may have moved or does not exist yet.</p> <a class="text-link" href="index.html#posts">Back to all posts</a> </div> ` return }
document.title = `${post.title} · Blog` container.innerHTML = ` <header class="post-header"> ${metadata(post)} <h1>${post.title}</h1> <p class="post-description">${post.description}</p> </header> <div class="post-body">${post.content}</div> ` }
renderPostList() renderPost()})()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="description" content="Notes on building software, systems, and useful things." /> <title>Blog</title> <link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet" /> <link rel="stylesheet" href="styles.css" /> </head> <body> <!-- THESIS: The blog shares the docs theme — same warm-beige / slate-violet palette, bubblegum accent, sharp corners, grain, and JetBrains Mono chrome. OWN-WORLD: Mono on chrome and code, sans prose, terminal-style code blocks, accent pips. STORY: Find a note by title, date, or summary, then read it. FIRST VIEWPORT: Small navigation, a direct Blog heading, and the beginning of the post list. FORM: Static HTML, CSS, and JavaScript; posts live in posts.js as HTML. FINISH: unreviewed and undocumented is unfinished; this build ends with the finish review, the verdict, and DESIGN.md --> <header class="site-header"> <div class="shell header-inner"> <a class="site-name" href="index.html"><span class="site-mark" aria-hidden="true"></span>Your Name</a> <nav aria-label="Primary navigation"> <a href="index.html">Blog</a> <a href="#about">About</a> <a href="feed.xml">RSS</a> </nav> </div> </header>
<main class="shell"> <section class="masthead" aria-labelledby="page-title"> <p class="kicker">Engineering notes</p> <h1 id="page-title">Blog</h1> <p>Notes on software, systems, and building things.</p> </section>
<section id="posts" aria-labelledby="posts-heading"> <div class="section-heading"> <h2 id="posts-heading">Posts</h2> <span id="post-count" class="muted"></span> </div> <div id="post-list" class="post-list" aria-live="polite"></div> </section>
<section class="about" id="about" aria-labelledby="about-heading"> <h2 id="about-heading">About</h2> <p> I’m a software engineer writing about reliable systems, developer tools, and the work between an idea and a working implementation. </p> </section> </main>
<footer class="site-footer"> <div class="shell footer-inner"> <span>© 2025 Your Name</span> <a href="mailto:you@example.com">Contact</a> </div> </footer>
<script src="posts.js"></script> <script src="blog.js"></script> </body></html>12345678910111213141516171819202122232425262728293031323334353637383940414243<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="description" content="An engineering blog post." /> <title>Blog</title> <link rel="preconnect" href="https://fonts.googleapis.com" /> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /> <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap" rel="stylesheet" /> <link rel="stylesheet" href="styles.css" /> </head> <body> <header class="site-header"> <div class="shell header-inner"> <a class="site-name" href="index.html"><span class="site-mark" aria-hidden="true"></span>Your Name</a> <nav aria-label="Primary navigation"> <a href="index.html">Blog</a> <a href="index.html#about">About</a> <a href="feed.xml">RSS</a> </nav> </div> </header>
<main class="shell post-shell"> <a class="back-link" href="index.html#posts">← Back to blog</a> <article id="post" class="post" aria-live="polite"></article> </main>
<footer class="site-footer"> <div class="shell footer-inner"> <span>© 2025 Your Name</span> <a href="mailto:you@example.com">Contact</a> </div> </footer>
<script src="posts.js"></script> <script src="blog.js"></script> </body></html>1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677// Add, remove, or generate posts here. Content is HTML so you can script and style it directly.// Each post is rendered by blog.js on index.html and post.html.
window.blogPosts = [ { slug: 'small-tools-last', title: 'The small tools I reach for last', description: 'A short list of utilities that quietly remove friction from everyday debugging.', date: '2025-04-18', tags: ['tools', 'workflow'], readingTime: '4 min read', content: ` <p>Good tools do not ask for much attention. They sit close to the work, make one awkward step easier, and then get out of the way.</p>
<p>This is a running list of small things I reach for when the obvious approach has stopped being useful. It is less a recommendation list than a reminder to keep the feedback loop short.</p>
<h2>Start with the boring measurement</h2> <p>Before changing a system, I want one concrete observation: a trace, a request duration, a file count, or even a timestamp around the suspicious line.</p>
<pre data-title="measure.js"><code>const startedAt = performance.now()await doTheThing()console.log("took", Math.round(performance.now() - startedAt), "ms")</code></pre>
<p>The exact tool matters less than making the invisible visible. Once there is a number, the next decision tends to get smaller.</p>
<h2>Keep the script nearby</h2> <p>If a command is useful more than once, it belongs in the repository. A tiny script with a clear name is often better than a paragraph in a team document.</p> `, }, { slug: 'one-more-boundary', title: 'One more boundary than feels necessary', description: 'Why explicit boundaries make distributed systems easier to change later.', date: '2025-03-07', tags: ['systems', 'architecture'], readingTime: '6 min read', content: ` <p>Most systems become difficult to change at the places where responsibilities were allowed to blur together.</p>
<p>A boundary can be a function, a process, a queue, or a data format. It gives the next change somewhere specific to land. The cost is a little ceremony now; the benefit is fewer accidental dependencies later.</p>
<blockquote>Make the boundary visible before you need to defend it.</blockquote>
<h2>Boundaries are for people, too</h2> <p>Interfaces are not only for computers. A good boundary tells the next person what they can rely on, what they need to provide, and where to look when something goes wrong.</p>
<ul> <li>Name the input and output.</li> <li>Keep failure close to the operation that caused it.</li> <li>Document the constraint that would surprise someone later.</li> </ul> `, }, { slug: 'notes-on-shipping', title: 'Notes on shipping a first version', description: 'A lightweight checklist for getting a useful version out without polishing the wrong thing.', date: '2025-01-22', tags: ['process'], readingTime: '3 min read', content: ` <p>The first version is not a smaller final version. It is an instrument for learning what deserves to become final.</p>
<p>I try to make the smallest version that can create a real observation. That usually means fewer settings, fewer abstractions, and a path that is easy to explain out loud.</p>
<h2>A practical first pass</h2> <ol> <li>Write down the one behavior that must work.</li> <li>Remove everything that does not help observe that behavior.</li> <li>Ship it to the smallest useful audience.</li> <li>Keep the notes from the first week.</li> </ol>
<p>Those notes are usually more valuable than the original plan. They show where the rough edges actually are.</p> `, },]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702/* * Blog — wisp.place theme * * Matches the docs and editor dashboard aesthetic: * Clean, flat, keyboard-first · sharp corners · tight spacing * JetBrains Mono on chrome/code · warm-beige light / slate-violet dark */
/* ── Color tokens ──────────────────────────────────────────────────────────── */
:root { color-scheme: light; --noise-opacity: 0.18;
--font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
/* Light — warm beige */ --bg: oklch(0.92 0.012 35); --bg-nav: oklch(0.88 0.01 35); --bg-accent: oklch(0.86 0.012 35); --ink: oklch(0.15 0.015 30); --muted: oklch(0.42 0.02 30); --faint: oklch(0.58 0.02 30); --line: oklch(0.60 0.02 30); --line-soft: oklch(0.72 0.02 30); --accent: oklch(0.65 0.18 345); --accent-high: oklch(0.48 0.22 345); --accent-low: oklch(0.90 0.06 345);
/* Terminal code block chrome (light) */ --term-bg: #f6f8fa; --term-header: #eaeef2; --term-border: oklch(0.60 0.02 30); --term-title: #57606a;
--max-width: 900px; --reading-width: 680px;}
/* Dark — slate violet */@media (prefers-color-scheme: dark) { :root { color-scheme: dark; --noise-opacity: 0.12;
--bg: oklch(0.23 0.015 285); --bg-nav: oklch(0.20 0.015 285); --bg-accent: oklch(0.28 0.015 285); --ink: oklch(0.90 0.005 285); --muted: oklch(0.78 0.01 285); --faint: oklch(0.62 0.01 285); --line: oklch(0.35 0.02 285); --line-soft: oklch(0.28 0.02 285); --accent: oklch(0.85 0.08 5); --accent-high: oklch(0.92 0.06 5); --accent-low: oklch(0.30 0.04 5);
/* Terminal code block chrome (dark) */ --term-bg: #0d1117; --term-header: #161b22; --term-border: oklch(0.32 0.02 285); --term-title: #8b949e; }}
/* ── Base ──────────────────────────────────────────────────────────────────── */
*,*::before,*::after { box-sizing: border-box; border-radius: 0 !important; /* Sharp corners */}
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: 16px; line-height: 1.55;}
/* * Grain texture — SVG fractal noise as a fixed overlay. * Same paper/matte quality as the docs. pointer-events: none so it * never interferes with interaction. */body::after { content: ""; position: fixed; inset: 0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E"); background-size: 200px 200px; opacity: var(--noise-opacity); mix-blend-mode: multiply; pointer-events: none; z-index: 9999;}
/* Scrollbar */::-webkit-scrollbar { width: 5px; height: 5px; }::-webkit-scrollbar-track { background: transparent; }::-webkit-scrollbar-thumb { background: var(--line); }::-webkit-scrollbar-thumb:hover { background: var(--faint); }
/* Selection — dimmed so it doesn't overpower the text */::selection { background: color-mix(in oklch, var(--accent) 25%, transparent); color: var(--ink); }::-moz-selection { background: color-mix(in oklch, var(--accent) 25%, transparent); color: var(--ink); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px;}
.shell { width: min(calc(100% - 3rem), var(--max-width)); margin: 0 auto;}
/* ── Header / chrome ───────────────────────────────────────────────────────── */
.site-header { background: var(--bg-nav); border-bottom: 1px solid var(--line); /* Thin accent stripe across the very top of the page */ box-shadow: 0 -3px 0 var(--accent) inset;}
.header-inner,.footer-inner { display: flex; align-items: center; justify-content: space-between; min-height: 68px; gap: 2rem;}
.site-name { display: inline-flex; align-items: center; font-family: var(--font-mono); font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; text-decoration: none; color: var(--ink);}
.site-name:hover { color: var(--accent);}
/* Small accent pip before the site name — echoes the heading pips */.site-mark { display: inline-block; width: 10px; height: 10px; margin-right: 0.6rem; background: var(--accent);}
nav { display: flex; gap: 1.6rem;}
nav a { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); text-decoration: none;}
nav a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px;}
/* ── Masthead ──────────────────────────────────────────────────────────────── */
.masthead { padding: 6.5rem 0 5rem;}
/* Small uppercase kicker above the title — like the docs group labels */.kicker { margin: 0 0 1.25rem; font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.18em; color: var(--accent);}
.masthead h1 { margin: 0; font-family: var(--font-mono); font-size: clamp(2.75rem, 7vw, 4.5rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1;}
.masthead p { max-width: 42ch; margin: 1.5rem 0 0; color: var(--muted); font-size: 1.05rem;}
/* ── Section headings ──────────────────────────────────────────────────────── */
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--line);}
.section-heading h2,.about h2 { margin: 0; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;}
/* Accent pip before section headings */.section-heading h2::before,.about h2::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--accent); opacity: 0.8; margin-right: 0.5rem; vertical-align: middle; position: relative; top: -1px;}
.muted { color: var(--faint); font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;}
/* ── Post list ─────────────────────────────────────────────────────────────── */
.post-list { border-bottom: 1px solid var(--line);}
.post-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem; align-items: center; padding: 1.8rem 0; border-bottom: 1px solid var(--line-soft);}
.post-row:last-child { border-bottom: 0;}
.post-row-content { display: block; text-decoration: none;}
.post-row-content:hover h3 { color: var(--accent);}
.post-meta { display: flex; flex-wrap: wrap; gap: 0.45rem; font-family: var(--font-mono); color: var(--faint); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;}
.post-row h3 { margin: 0.5rem 0 0.4rem; font-family: var(--font-mono); font-size: 1.2rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; transition: color 0.15s;}
.post-row p { max-width: 58ch; margin: 0; color: var(--muted);}
.read-link { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); white-space: nowrap; text-decoration: none;}
.read-link:hover { color: var(--accent-high); text-decoration: underline; text-underline-offset: 4px;}
/* ── About ─────────────────────────────────────────────────────────────────── */
.about { max-width: 600px; margin: 7rem 0; padding-top: 1rem; border-top: 1px solid var(--line);}
.about p { max-width: 54ch; margin: 1rem 0 0; color: var(--muted);}
/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state { padding: 2rem 0; color: var(--muted);}
.empty-state h1 { margin: 0 0 0.5rem; color: var(--ink); font-family: var(--font-mono); font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em;}
.text-link { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); text-decoration: none;}
.text-link:hover { color: var(--accent-high); text-decoration: underline; text-underline-offset: 4px;}
/* ── Footer ────────────────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-nav); color: var(--faint); font-family: var(--font-mono); font-size: 0.72rem;}
.footer-inner { min-height: 76px;}
.footer-inner a { color: var(--muted); text-decoration: none;}
.footer-inner a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px;}
/* ── Post ──────────────────────────────────────────────────────────────────── */
.post-shell { padding: 4rem 0 7rem;}
.back-link { display: inline-block; margin-bottom: 4rem; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); text-decoration: none;}
.back-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px;}
.post { max-width: var(--reading-width); margin: 0 auto;}
.post-header { padding-bottom: 3rem; border-bottom: 1px solid var(--line);}
.post-header h1 { max-width: 18ch; margin: 0.9rem 0 1rem; font-family: var(--font-mono); font-size: clamp(1.9rem, 4.5vw, 2.75rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;}
.post-description { max-width: 55ch; margin: 0; color: var(--muted); font-size: 1.15rem;}
.post-body { padding-top: 3rem; font-size: 1.08rem; line-height: 1.8;}
.post-body > * { margin-top: 0; margin-bottom: 1.5rem;}
/* Headings — accent pips like the docs content */.post-body h2 { margin-top: 3rem; margin-bottom: 0.75rem; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; border-bottom: 1px solid var(--line); padding-bottom: 0.35rem;}
.post-body h2::before { content: ""; display: inline-block; width: 8px; height: 8px; background: var(--accent); opacity: 0.8; margin-right: 0.5rem; vertical-align: middle; position: relative; top: -1px;}
.post-body h3 { margin-top: 2rem; margin-bottom: 0.5rem; font-size: 1.05rem; font-weight: 600;}
.post-body h3::before { content: ""; display: inline-block; width: 5px; height: 5px; background: var(--accent); opacity: 0.5; margin-right: 0.45rem; vertical-align: middle; position: relative; top: -1px;}
/* Links — animated underline wipe, same as docs */.post-body a { color: var(--accent); text-decoration: none; background-image: linear-gradient(var(--accent), var(--accent)); background-size: 0% 1px; background-repeat: no-repeat; background-position: left bottom; transition: background-size 0.2s ease, color 0.15s;}
.post-body a:hover { background-size: 100% 1px; color: var(--accent-high);}
.post-body ul,.post-body ol { padding-left: 1.5rem;}
.post-body li + li { margin-top: 0.4rem;}
.post-body blockquote { margin: 2rem 0; padding: 0.6rem 1.25rem; border-left: 2px solid var(--accent); background: var(--bg-accent); color: var(--muted);}
.post-body hr { border: none; border-top: 1px solid var(--line); margin: 1.5rem 0;}
.post-body strong { color: var(--ink); font-weight: 700;}
/* Tables — same treatment as docs */.post-body table { width: 100%; border-collapse: collapse; font-size: 0.875rem; margin: 1.5rem 0;}
.post-body th { background: var(--bg-accent); border: 1px solid var(--line); padding: 0.4rem 0.75rem; text-align: left; font-family: var(--font-mono); font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);}
.post-body td { border: 1px solid var(--line); padding: 0.4rem 0.75rem;}
.post-body tr:hover td { background: var(--bg-accent);}
/* ── Code ──────────────────────────────────────────────────────────────────── */
/* Inline code */.post-body :not(pre) > code { font-family: var(--font-mono); font-size: 0.875em; background: var(--bg-accent); border: 1px solid var(--line); padding: 0.1em 0.35em; color: var(--accent);}
/* Terminal code blocks — titlebar with traffic-light dots */.post-body pre { position: relative; overflow: hidden; margin: 2rem 0; padding: 2.75rem 1.25rem 1.25rem; background: var(--term-bg); border: 1px solid var(--term-border); font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.65;}
/* Titlebar: header strip + three dots drawn as a single background */.post-body pre::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2.25rem; background-color: var(--term-header); border-bottom: 1px solid var(--term-border); background-image: radial-gradient(circle at 5px 6px, #ff5f56 4.5px, transparent 4.5px), radial-gradient(circle at 20px 6px, #ffbd2e 4.5px, transparent 4.5px), radial-gradient(circle at 35px 6px, #27ca40 4.5px, transparent 4.5px); background-position: 12px 50%; background-repeat: no-repeat; width: 40px; transition: filter 0.2s;}
.post-body pre:hover::before { filter: brightness(1.2) drop-shadow(0 0 3px #ff5f5688);}
/* Optional file title, right-aligned in the titlebar (pre[data-title]) */.post-body pre::after { content: attr(data-title); position: absolute; top: 0; right: 1rem; line-height: 2.25rem; font-family: var(--font-mono); font-size: 0.72rem; color: var(--term-title);}
.post-body pre code { font-family: var(--font-mono); font-size: inherit; background: transparent; border: none; padding: 0; color: var(--ink);}
/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) { .shell { width: min(calc(100% - 2rem), var(--max-width)); }
.header-inner { min-height: 62px; }
nav { gap: 0.9rem; }
nav a { font-size: 0.64rem; }
.masthead { padding: 5rem 0 3.5rem; }
.post-row { display: block; padding: 1.5rem 0; }
.read-link { display: inline-block; margin-top: 0.9rem; }
.about { margin: 5rem 0; }
.footer-inner { align-items: flex-start; flex-direction: column; justify-content: center; gap: 0.25rem; }}4 unmodified lines56789910111213141516171819204 unmodified linesENV DEBIAN_FRONTEND=noninteractiveENV E2E_CHROMIUM_EXECUTABLE=/usr/bin/chromium
RUN apt-get update && \ apt-get install -y --no-install-recommends ca-certificates chromium fonts-liberation && \ apt-get install -y --no-install-recommends ca-certificates chromium ffmpeg fonts-liberation && \ rm -rf /var/lib/apt/lists/*
COPY . .
RUN bun install --frozen-lockfile
RUN bunx playwright install ffmpeg
WORKDIR /app/apps/main-app
CMD ["bun", "e2e/wisp-e2e.ts"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279import { mkdir } from 'node:fs/promises'import { setTimeout as delay } from 'node:timers/promises'import { type BrowserContext, chromium, type Page } from 'playwright'
const env = (name: string, fallback: string) => process.env[name] || fallbackconst appUrl = env('E2E_APP_URL', 'http://127.0.0.1:8000').replace(/\/$/, '')const appUpstream = env('E2E_APP_UPSTREAM', 'http://main-app:8000').replace(/\/$/, '')const hostingUrl = env('E2E_HOSTING_URL', 'http://hosting-service:3001').replace(/\/$/, '')const hostingBrowserUrl = env('E2E_HOSTING_BROWSER_URL', 'http://127.0.0.1:3001').replace(/\/$/, '')const pdsBrowserUrl = env('E2E_PDS_BROWSER_URL', 'http://127.0.0.1:3300').replace(/\/$/, '')const pdsUpstream = env('E2E_PDS_UPSTREAM', 'http://pds:3300').replace(/\/$/, '')const atprotoPassword = env('E2E_ATPROTO_PASSWORD', 'alice-dev-password')const timeoutMs = Number.parseInt(env('E2E_TIMEOUT_MS', '180000'), 10)const artifactsDir = env('E2E_ARTIFACTS_DIR', '/artifacts')const chromiumExecutable = process.env.E2E_CHROMIUM_EXECUTABLE || undefined
type Auth = { handle: string; did: string; password: string }type JsonResponse<T = Record<string, unknown>> = { status: number; data: T; text: string }
const alice: Auth = { handle: env('E2E_ATPROTO_HANDLE', 'alice.test'), did: '', password: atprotoPassword }const bob: Auth = { handle: env('E2E_AUDIENCE_HANDLE', 'bob.test'), did: '', password: env('E2E_AUDIENCE_PASSWORD', 'bob-dev-password'),}
function proxy(listen: string, upstream: string, preserveHost = false) { const listenUrl = new URL(listen) const upstreamUrl = new URL(upstream) return Bun.serve({ hostname: listenUrl.hostname, port: Number(listenUrl.port || 80), async fetch(request) { const incoming = new URL(request.url) const target = new URL(`${incoming.pathname}${incoming.search}`, upstreamUrl) const headers = new Headers(request.headers) headers.set('accept-encoding', 'identity') if (preserveHost) headers.set('host', incoming.host) else headers.delete('host') headers.set('x-forwarded-host', listenUrl.host) headers.set('x-forwarded-proto', listenUrl.protocol.replace(':', '')) return fetch(target, { method: request.method, headers, body: request.method === 'GET' || request.method === 'HEAD' ? undefined : request.body, redirect: 'manual', }) }, })}
async function waitFor(url: string) { const started = Date.now() while (Date.now() - started < timeoutMs) { try { if ((await fetch(url)).ok) return } catch {} await delay(1000) } throw new Error(`timed out waiting for ${url}`)}
async function json<T>(page: Page, path: string, init?: RequestInit): Promise<JsonResponse<T>> { return page.evaluate( async ({ path, init }) => { const response = await fetch(path, { credentials: 'include', ...init } as any) const text = await response.text() let data: Record<string, unknown> = {} try { data = text ? JSON.parse(text) : {} } catch {} return { status: response.status, data, text } }, { path, init }, ) as Promise<JsonResponse<T>>}
async function login(page: Page, account: Auth): Promise<string> { await page.goto(`${appUrl}/api/auth/login?login_hint=${encodeURIComponent(account.handle)}`, { waitUntil: 'commit', timeout: timeoutMs, }) const started = Date.now() while (Date.now() - started < timeoutMs) { if (page.url().startsWith(appUrl)) { const status = (await page .evaluate(() => fetch('/api/auth/status', { credentials: 'include' }).then((r) => r.json())) .catch(() => null)) as { authenticated?: boolean; did?: string } | null if (status?.authenticated && status.did) { account.did = status.did return status.did } } const identifier = page .locator( 'input[name="identifier"]:not([disabled]):not([readonly]), input[name="handle"]:not([disabled]):not([readonly]), input[autocomplete="username"]:not([disabled]):not([readonly]), input[placeholder*="handle" i]:not([disabled]):not([readonly])', ) .first() const password = page .locator( 'input[type="password"]:not([disabled]):not([readonly]), input[autocomplete="current-password"]:not([disabled]):not([readonly])', ) .first() if (await identifier.isVisible().catch(() => false)) await identifier.fill(account.handle) if (await password.isVisible().catch(() => false)) await password.fill(account.password) const button = page.getByRole('button', { name: /next|continue|log in|sign in|authorize|allow|accept/i }).first() if ((await button.isVisible().catch(() => false)) && (await button.isEnabled().catch(() => false))) await button.click() else await page.keyboard.press('Enter').catch(() => undefined) await Promise.race([page.waitForLoadState('networkidle', { timeout: 2000 }).catch(() => undefined), delay(750)]) } throw new Error(`timed out signing in ${account.handle}`)}
async function screenshot(page: Page, name: string) { await page.screenshot({ path: `${artifactsDir}/${name}.png`, fullPage: true })}
async function upload(page: Page): Promise<{ siteId: string; url: string }> { const result = await page.evaluate(async () => { const form = new FormData() form.append('name', 'agent architecture review') form.append( 'files', new File( [ `<!doctype html><html><head><title>agent architecture review</title><link rel="stylesheet" href="/report.css"></head><body><main><p class="eyebrow">private report</p><h1>permissioned data, in practice</h1><p>this is an owner-only report rendered from the private storage origin.</p><details open><summary>the honest tradeoff</summary><p>wisp can read and serve this content; it is access control, not encryption.</p></details></main></body></html>`, ], 'index.html', { type: 'text/html' }, ), ) form.append( 'files', new File( [ 'body { font-family: system-ui; max-width: 48rem; margin: 12vh auto; padding: 2rem; color: #24202a; } .eyebrow { text-transform: uppercase; letter-spacing: .15em; color: #d34d78; }', ], 'report.css', { type: 'text/css' }, ), ) const response = await fetch('/api/user/private-sites/', { method: 'POST', body: form, credentials: 'include' }) const text = await response.text() return { status: response.status, data: JSON.parse(text) as { siteId: string; url: string; success?: boolean }, text, } }) if (result.status !== 200 || !result.data.success) throw new Error(`private upload failed: ${result.status} ${result.text}`) return result.data}
async function main() { await mkdir(artifactsDir, { recursive: true }) const proxies = [ proxy(appUrl, appUpstream), proxy(pdsBrowserUrl, pdsUpstream, true), proxy(hostingBrowserUrl, hostingUrl, true), ] const browser = await chromium.launch({ headless: true, executablePath: chromiumExecutable }) const contexts: BrowserContext[] = [] try { await waitFor(`${appUpstream}/api/health`) await waitFor(`${hostingUrl}/health`) const owner = await browser.newContext({ baseURL: appUrl, ignoreHTTPSErrors: true, recordVideo: { dir: `${artifactsDir}/video`, size: { width: 1440, height: 1000 } }, }) contexts.push(owner) const ownerPage = await owner.newPage() await login(ownerPage, alice) const site = await upload(ownerPage) const siteUrl = site.url.replace('http://', `${hostingBrowserUrl.split('://')[0]}://`).replace(/:\d+\//, ':3001/') console.log(`[capture] site=${site.siteId} url=${siteUrl}`)
const ownerOpen = await json<{ success?: boolean; url?: string }>( ownerPage, `/api/user/private-sites/${site.siteId}/open`, { method: 'POST' }, ) if (!ownerOpen.data.url) throw new Error(`owner open failed: ${ownerOpen.status} ${ownerOpen.text}`) await ownerPage.goto(ownerOpen.data.url, { waitUntil: 'domcontentloaded' }) await screenshot(ownerPage, '01-owner-private-site') await ownerPage.goto(`${appUrl}/onboarding`, { waitUntil: 'domcontentloaded' })
const anonymous = await browser.newContext({ ignoreHTTPSErrors: true, recordVideo: { dir: `${artifactsDir}/video`, size: { width: 1440, height: 1000 } }, }) contexts.push(anonymous) const anonymousPage = await anonymous.newPage() const anonymousResponse = await anonymousPage.goto(siteUrl, { waitUntil: 'domcontentloaded' }) if (anonymousResponse?.status() !== 200 || !(await anonymousPage.getByText('private site').count())) throw new Error('anonymous private-site denial was not shown') await screenshot(anonymousPage, '02-anonymous-access-denied')
const share = await json<{ success?: boolean; shareId?: string; url?: string; directUrl?: string }>( ownerPage, `/api/user/private-sites/${site.siteId}/shares`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ label: 'bob review', audienceDid: await resolveDid(bob.handle) }), }, ) if (!share.data.shareId || !share.data.directUrl) throw new Error(`share creation failed: ${share.status} ${share.text}`) await screenshot(ownerPage, '03-share-link-created')
const audience = await browser.newContext({ ignoreHTTPSErrors: true, recordVideo: { dir: `${artifactsDir}/video`, size: { width: 1440, height: 1000 } }, }) contexts.push(audience) const audiencePage = await audience.newPage() await audiencePage.goto(share.data.directUrl, { waitUntil: 'domcontentloaded' }) if (!(await audiencePage.getByText('this link is for a specific account').count())) throw new Error('audience sign-in gate was not shown') await screenshot(audiencePage, '04-audience-restricted-sign-in')
const bobContext = await browser.newContext({ baseURL: appUrl, ignoreHTTPSErrors: true, recordVideo: { dir: `${artifactsDir}/video`, size: { width: 1440, height: 1000 } }, }) contexts.push(bobContext) const bobPage = await bobContext.newPage() await login(bobPage, bob) const redeem = await bobContext.request.post(`${appUrl}/private/redeem`, { form: { siteId: site.siteId, token: new URL(share.data.directUrl).searchParams.get('wisp_share') || '', }, headers: { Origin: appUrl }, maxRedirects: 0, }) const grant = redeem.headers().location if (redeem.status() !== 303 || !grant) throw new Error(`audience redeem failed: ${redeem.status()} ${await redeem.text()}`) await bobPage.goto(grant, { waitUntil: 'domcontentloaded' }) if (!(await bobPage.getByText('permissioned data, in practice').count())) throw new Error( `audience account could not open site: ${bobPage.url()} ${await bobPage.locator('body').innerText()}`, ) await screenshot(bobPage, '05-audience-site-open')
const revoke = await json(ownerPage, `/api/user/private-sites/${site.siteId}/shares/${share.data.shareId}`, { method: 'DELETE', }) if (revoke.status !== 200) throw new Error(`share revoke failed: ${revoke.status} ${revoke.text}`) await bobPage.reload({ waitUntil: 'domcontentloaded' }) if ((await bobPage.locator('body').innerText()).includes('permissioned data, in practice')) throw new Error('revoked audience session still served private content') await screenshot(bobPage, '06-revoked-share-denied') console.log('[capture] completed private-site evidence capture') } finally { for (const context of contexts) await context.close() await browser.close() for (const server of proxies) server.stop(true) }}
async function resolveDid(handle: string): Promise<string> { const response = await fetch( `${pdsUpstream}/xrpc/com.atproto.identity.resolveHandle?handle=${encodeURIComponent(handle)}`, ) const result = (await response.json()) as { did?: string } if (!response.ok || !result.did) throw new Error(`could not resolve ${handle}`) return result.did}
main().catch((error) => { console.error('[capture] failed', error) process.exit(1)})