// HTML builders used by slides.mjs. Everything here runs at build time in Node
// and returns markup strings for the generated HyperFrames composition.
export const html = String.raw
export const TOPIC_NAMES = {
search: 'search',
execute: 'execute',
mcp: 'MCP',
cli: 'CLI',
api: 'API',
memory: 'memory',
packages: 'packages',
triggers: 'triggers',
credentials: 'credentials',
apps: 'apps',
sharing: 'sharing',
}
export function esc(s) {
// `{` as an entity: code samples show secret placeholders, and the literal
// text in built HTML reads as a credential use to Kody's publish checks.
return String(s).replace(/&/g, '&').replace(//g, '>').replace(/\{/g, '{').replace(/\}/g, '}').replace(/:/g, ':')
}
// Every topic gets the same mark: a disc in its hue with a drawn icon.
export const TOPIC_HUES = {
search: '#06b6d4',
execute: '#10b981',
mcp: '#6366f1',
cli: '#84cc16',
api: '#64748b',
memory: '#ef4444',
packages: '#3b82f6',
triggers: '#eab308',
credentials: '#22c55e',
apps: '#a855f7',
sharing: '#ec4899',
secrets: '#14b8a6',
}
const ICONS = {
search: '',
execute: '',
mcp: '',
api: '',
cli: '',
sharing:
'',
memory: '',
packages:
'',
triggers: '',
credentials: '',
apps: '',
secrets: '',
}
/** A topic's mark: a disc in its hue with a white drawn icon. */
export function badge(topic, size = 96, { float = true, id = '', cls = '' } = {}) {
const hue = TOPIC_HUES[topic]
const r = (n) => Math.round(size * n)
const inner = ``
return `${inner}`
}
/** Features in a room or a list. Same mark as everywhere else. */
export const orb = (name, size = 96, opts = {}) => badge(name, size, opts)
// Agents are picked at random on every load (page.js assignAgents), from the
// coding agents Kody's site has logos for.
export const AGENT_POOL = [
'claudecode',
'claude',
'chatgpt',
'codex',
'cursor',
'gemini',
'goose',
'openclaw',
'zed',
'githubcopilot',
'devin',
'amp',
'warp',
'grok',
'grokbot',
'pi',
]
/**
* An agent logo slot. Slots in the same group get distinct agents; slots that
* share a group and an index always show the same agent (so "your" agent stays
* yours from slide to slide).
*/
export function agent(group, index, size = 56, { cls = '' } = {}) {
return ``
}
/** A mouse pointer whose tip rests on the center of its (positioned) parent. */
export function cursor(id) {
return ``
}
export function cfLogo(size = 34) {
return ``
}
export function person(color = '', { id = '', name = '', style = '' } = {}) {
const disc = `
`
}
export function house({ id, x, y, agent: logo = '', room = '', roomId = '', extra = '' }) {
return html`
${logo}
${room}
${extra}
`
}
// ---------------------------------------------------------------- code
const KEYWORDS = new Set([
'import',
'from',
'export',
'default',
'async',
'function',
'await',
'const',
'return',
'let',
'new',
])
/** Minimal JS highlighter. Wrap a span of a line in ⟦…⟧ to mark it highlighted. */
export function highlight(src) {
const out = []
const re =
/(\/\/[^\n]*)|('(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`|"(?:[^"\\]|\\.)*")|([A-Za-z_$][\w$]*)(?=\s*\()|([A-Za-z_$][\w$]*)|(⟦|⟧)|([\s\S])/g
let m
while ((m = re.exec(src))) {
const [, com, str, fn, word, mark, other] = m
if (com) out.push(`${esc(com)}`)
else if (str) out.push(`${esc(str)}`)
else if (fn) out.push(KEYWORDS.has(fn) ? `${fn}` : `${fn}`)
else if (word) out.push(KEYWORDS.has(word) ? `${word}` : word)
else if (mark) out.push(mark === '⟦' ? '' : '')
else out.push(esc(other))
}
return out.join('')
}
/** Code card. Each line gets its own span so lines can be revealed or highlighted. */
export function code(src, { id, x, y, w, size } = {}) {
// ⟪ ⟫ stand in for double braces, so a credential placeholder shown on a slide
// never appears as a string in this package's source (Kody's publish checks
// read string literals and would treat it as a real credential use)
src = src.replace(/⟪/g, '{'.repeat(2)).replace(/⟫/g, '}'.repeat(2))
const lines = src.replace(/^\n|\n\s*$/g, '').split('\n')
const body = lines.map((l, i) => `${highlight(l) || ' '}`).join('\n')
return `
${body}
`
}
export function term(lines, { id, x, y, w }) {
const body = lines.map((l, i) => `