← Public packages
@kentcdodds/invisible-software-talk
Invisible Software: Kent C. Dodds's AI Coding Summit NYC 2026 talk deck. Agents become software's next billion users.
Files
// Builds one fully self-contained Reveal.js page from src/deck.html + src/slides/*.html (file-name
// order). Reveal.js and its notes plugin come from the pinned npm package and are inlined with the
// fonts, images, CSS and JS. Writes dist/index.html (the offline build) and app/assets.generated.ts
// (served by the Kody app).
import { readdirSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs'
import { join, extname } from 'node:path'
import { createHash } from 'node:crypto'
import QRCode from 'qrcode'
import { buildDemo } from './build-demo.mjs'
const root = new URL('..', import.meta.url).pathname
const src = join(root, 'src')
const types = { '.png': 'image/png', '.svg': 'image/svg+xml', '.woff2': 'font/woff2', '.ico': 'image/x-icon', '.webp': 'image/webp', '.jpg': 'image/jpeg', '.html': 'text/html; charset=utf-8' }
const dataUri = (rel) => {
const file = join(src, 'c', rel)
const type = types[extname(file)]
if (!type) throw new Error(`No content type for ${rel}`)
return `data:${type};base64,${readFileSync(file).toString('base64')}`
}
// Rewrites `@scope { a, b { ... } }` into rules prefixed with the slide's selector.
function scopeCss(css, sel) {
// Drop comments first: commas inside a comment would otherwise split into bogus selectors.
css = css.replace(/\/\*[\s\S]*?\*\//g, '')
return css.replace(/@scope\s*\{([\s\S]*)\}\s*$/m, (_, body) =>
body.replace(/([^{}]+)\{([^{}]*)\}/g, (_, selectors, decls) => {
const out = selectors.split(',').map((s) => s.trim()).filter(Boolean).map((s) =>
s.includes(':scope') ? s.replace(':scope', sel) : `${sel} ${s}`,
)
return `\n${out.join(', ')} {${decls}}`
}),
)
}
// House style for everything we write: no em or en dashes and ASCII quotes only.
{
const files = [
...readdirSync(join(src, 'slides')).filter((f) => f.endsWith('.html')).map((f) => join(src, 'slides', f)),
...['README.md', 'AGENTS.md', 'BEATS.md', 'src/deck.html', 'src/c/deck.css', 'src/c/deck.js', 'src/c/demo.js', 'src/c/scenes.js', 'src/sw.js'].map((f) => join(root, f)),
]
const bad = []
for (const file of files) {
let text
try { text = readFileSync(file, 'utf8') } catch { continue }
text.split('\n').forEach((line, i) => {
const m = line.match(/[–—‘’“”]/)
if (m) bad.push(`${file.slice(root.length)}:${i + 1}: ${JSON.stringify(m[0])}`)
})
}
if (bad.length) throw new Error(`house style (no em/en dashes, ASCII quotes):\n${bad.join('\n')}`)
}
// Brand marks and Kody Iconic glyphs, inlined so they follow the theme via currentColor.
const snippets = {
KODY_MARK: readFileSync(join(src, 'c/kody-mark.svg.html'), 'utf8').trim(),
TREND_JSON: readFileSync(join(src, 'c/data-trend.json'), 'utf8').trim(),
QR_DECK: (await QRCode.toString('https://invisible-software-slides.kentcdodds.com/', { type: 'svg', margin: 0, errorCorrectionLevel: 'M' })).replace('<svg ', '<svg class="qr" aria-label="QR code for invisible-software-slides.kentcdodds.com" '),
...JSON.parse(readFileSync(join(src, 'c/icons.json'), 'utf8')),
}
// Each inlined copy of an SVG with internal ids (the EpicProduct.engineer gradient) gets its own
// ids: a url(#id) that points at a copy inside a hidden slide would render nothing.
let snippetCopy = 0
const fill = (html) => html.replace(/\{\{([A-Z_]+)\}\}/g, (m, k) => {
if (!(k in snippets)) throw new Error(`unknown snippet ${m}`)
const n = ++snippetCopy
return snippets[k].replace(/id="([\w-]+)"/g, (_, id) => `id="${id}-${n}"`).replace(/url\(#([\w-]+)\)/g, (_, id) => `url(#${id}-${n})`)
})
const slideFiles = readdirSync(join(src, 'slides')).filter((f) => f.endsWith('.html')).sort()
const labels = new Set()
const slidesHtml = slideFiles.map((f) => {
let html = readFileSync(join(src, 'slides', f), 'utf8').trim()
const label = html.match(/^<section id="([\w-]+)"/)?.[1]
if (!label) throw new Error(`${f}: must start with <section id="...">`)
if (labels.has(label)) throw new Error(`${f}: duplicate label ${label}`)
if (!/<aside class="notes">[\s\S]*?\S[\s\S]*?<\/aside>/.test(html)) throw new Error(`${f}: missing speaker notes`)
labels.add(label)
return fill(html).replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => `<style>${scopeCss(css, `.reveal .slides section#${label}`)}</style>`)
}).join('\n')
const readAsset = (f) => (f.startsWith('vendor:') ? readFileSync(join(root, 'node_modules', f.slice(7)), 'utf8') : readFileSync(join(src, 'c', f), 'utf8'))
const inlineJs = (t) => t.replace(/<\/script/gi, '<\\/script').replace(/^\/\/# sourceMappingURL=.*$/gm, '')
const inlineCss = (t) => t.replace(/^\/\*# sourceMappingURL=.*$/gm, '')
// One page source, two outputs: dist/index.html with every asset inlined (opens from disk with zero
// network), and the hosted index.html that references content-hashed files under c/.
const pageSrc = readFileSync(join(src, 'deck.html'), 'utf8')
.replace(/<link rel="stylesheet" href="([\w.:/-]+)">/g, (_, f) => `<style>\n${inlineCss(readAsset(f))}\n</style>`)
.replace(/<script src="([\w.:/-]+)"><\/script>/g, (_, f) => `<script>\n${inlineJs(readAsset(f))}\n</script>`)
.replace('<!-- slides -->', () => slidesHtml)
// Offline file: everything inlined. The phone demo document is a JS string (every < escaped so
// nothing in it can close the script) that src/c/demo.js loads as an iframe srcdoc.
let page = pageSrc
.replace('<!-- demo -->', () => `<script>\nwindow.__DEMO_HTML = ${JSON.stringify(buildDemo()).replace(/</g, '\\u003c')}\n</script>`)
.replace(/url\('(fonts|img)\/([\w.-]+)'\)/g, (_, d, f) => `url('${dataUri(d + '/' + f)}')`)
.replace(/(src|href)="c\/([\w./-]+)"/g, (_, attr, p) => `${attr}="${dataUri(p)}"`)
const markup = page.replace(/<script>[\s\S]*?<\/script>/g, '').replace(/<a ([^>]*?)href="https:\/\/[^"]+"/g, '<a $1')
// url(#id) is a same-document SVG reference, not a fetch.
const bad = markup.match(/(?:src|href)="(?!data:|#)[^"]*"|url\((?!['"]?(?:data:|#))[^)]*\)/)
if (bad) throw new Error(`page still references an external or relative resource: ${bad[0].slice(0, 120)}`)
mkdirSync(join(root, 'dist'), { recursive: true })
writeFileSync(join(root, 'dist/index.html'), page)
// Hosted: binary assets become separate files named by content hash (c/img/name.<hash>.webp), served
// with immutable cache headers, so a text edit never re-downloads an image.
const hashed = {}
const publish = (path, buf) => {
const type = types[extname(path)]
if (!type) throw new Error(`No content type for ${path}`)
const h = createHash('sha256').update(buf).digest('hex').slice(0, 8)
const out = `${path.slice(0, -extname(path).length)}.${h}${extname(path)}`
hashed[out] = type.startsWith('text/') ? { type, text: buf.toString('utf8') } : { type, base64: buf.toString('base64') }
return out
}
const deckAsset = (rel) => publish(`c/${rel}`, readFileSync(join(src, 'c', rel)))
// The demo document lives at c/demo.<hash>.html, so its own assets are referenced relative to c/.
const demoHtml = buildDemo((rel) => deckAssetFromDemo(rel))
function deckAssetFromDemo(rel) {
return publish(`c/demo/${rel}`, readFileSync(join(root, 'demo', 'c', rel))).slice(2)
}
const demoPath = publish('c/demo.html', Buffer.from(demoHtml, 'utf8'))
let hostedPage = pageSrc
.replace(/url\('(fonts|img)\/([\w.-]+)'\)/g, (_, d, f) => `url('${deckAsset(d + '/' + f)}')`)
.replace(/(src|href)="c\/([\w./-]+)"/g, (_, attr, p) => `${attr}="${deckAsset(p)}"`)
// Everything the service worker precaches: the page (''), the PWA files and every hashed asset.
const precache = ['', 'favicon.ico', 'manifest.webmanifest', 'icon-192.png', 'icon-512.png', ...Object.keys(hashed).sort()]
hostedPage = hostedPage.replace('<!-- demo -->', () => `<script>\nwindow.__DEMO_URL = ${JSON.stringify(demoPath)}\nwindow.__PRECACHE = ${JSON.stringify(precache)}\n</script>`)
{
const m = hostedPage.replace(/<script>[\s\S]*?<\/script>/g, '').replace(/<a ([^>]*?)href="https:\/\/[^"]+"/g, '<a $1')
for (const r of m.matchAll(/(?:src|href)="([^"]*)"|url\(['"]?([^)'"]*)['"]?\)/g)) {
const u = r[1] ?? r[2]
if (/^(data:|#)/.test(u)) continue
if (!hashed[u]) throw new Error(`hosted page references ${u.slice(0, 120)}, which is not a published asset`)
}
// Reveal's CSS carries its own tiny loading-spinner GIF; our images and fonts must all be files.
const inlined = m.match(/.{0,80}data:(?:image\/(?:png|jpeg|webp)|font\/).{0,40}/)
if (inlined) throw new Error(`hosted page still inlines a binary image or font: ${inlined[0]}`)
}
// PWA: the service worker precaches the page and every hashed asset. Its cache name is versioned by
// the page and asset hashes, so each publish replaces the old copy.
const version = createHash('sha256').update(hostedPage).update(precache.join()).digest('hex').slice(0, 12)
const sw = readFileSync(join(src, 'sw.js'), 'utf8').replace('__VERSION__', version).replace('__PRECACHE__', JSON.stringify(precache))
const manifest = JSON.stringify({
name: 'Invisible Software',
short_name: 'Invisible SW',
description: "Kent C. Dodds's talk deck. Works offline once loaded.",
start_url: './',
scope: './',
display: 'fullscreen',
display_override: ['fullscreen', 'standalone'],
background_color: '#111417',
theme_color: '#111417',
icons: [
{ src: 'icon-192.png', sizes: '192x192', type: 'image/png', purpose: 'any' },
{ src: 'icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'any' },
],
}, null, '\t')
const assets = {
'index.html': { type: 'text/html; charset=utf-8', text: hostedPage },
'favicon.ico': { type: 'image/x-icon', base64: readFileSync(join(src, 'c/icons/favicon.ico')).toString('base64') },
'sw.js': { type: 'text/javascript; charset=utf-8', text: sw },
'manifest.webmanifest': { type: 'application/manifest+json', text: manifest },
'icon-192.png': { type: 'image/png', base64: readFileSync(join(src, 'c/icons/icon-192.png')).toString('base64') },
'icon-512.png': { type: 'image/png', base64: readFileSync(join(src, 'c/icons/icon-512.png')).toString('base64') },
...hashed,
}
writeFileSync(join(root, 'app/assets.generated.ts'), `// Generated by scripts/build.mjs. Do not edit by hand.
export type Asset = { type: string; text?: string; base64?: string }
export const slideCount = ${slideFiles.length}
export const assets: Record<string, Asset> = ${JSON.stringify(assets, null, '\t')}
`)
const kib = (n) => `${(n / 1024).toFixed(0)} KiB`
const assetBytes = Object.values(hashed).reduce((n, a) => n + (a.text?.length ?? (a.base64.length * 3) / 4), 0)
console.log(`Composed ${slideFiles.length} slides (${[...labels].join(', ')}). dist/index.html is ${kib(page.length)}; hosted index.html is ${kib(hostedPage.length)} plus ${Object.keys(hashed).length} hashed assets (${kib(assetBytes)}).`)