gooseworks-ai/goose-skills / skills/video/create-chatgpt-mockup
create-chatgpt-mockup
VerifiedRender pixel-accurate ChatGPT mobile (iOS) screen mockups in light mode from a thread JSON. Supports user text bubbles, user image attachments, assistant markdown prose, citation chips, the OpenAI spiral logo, the Apps-SDK GPT chip in the composer, and three header styles (model-tag, plain title, "Get Plus"). Fixed 9:16 viewport. Outputs HTML + PNG.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 14.9 KB |
| examples/01-sunscreen-image.json | config | 467 B |
| examples/02-sleep-apnea-long.json | config | 1.1 KB |
| examples/03-poem-iphone-mac.json | config | 1007 B |
| examples/04-empty-typing.json | config | 258 B |
| examples/05-seatfinch-gpt-chip.json | config | 596 B |
| examples/06-short-howto.json | config | 750 B |
| examples/assets/sunscreen-sky.svg | other | 3.1 KB |
| generate.js | script | 16.3 KB |
| package.json | manifest | 348 B |
| render.js | script | 3.0 KB |
| screenshot.js | script | 2.5 KB |
| skill.meta.json | config | 136 B |
| templates/chat.css | other | 16.6 KB |
| templates/icons.js | script | 11.5 KB |
| tests/expected-output.md | markdown | 2.8 KB |
| tests/human-test.md | markdown | 1.8 KB |
| tests/run-all.shexecutable | script | 414 B |
| tests/sample-input.md | markdown | 1.8 KB |
| tests/smoke-test.md | markdown | 796 B |
generate.js
View on GitHub#!/usr/bin/env node
/**
* generate.js ā Convert a ChatGPT thread JSON into a single HTML page that
* mimics the ChatGPT mobile (iOS) app in light mode.
*
* Usage:
* const { renderHTML } = require('./generate');
* const html = renderHTML(thread);
* node generate.js --thread examples/text-only.json --out /tmp/index.html
*/
const fs = require('fs');
const path = require('path');
const ICONS = require('./templates/icons');
function escapeHTML(s) {
return String(s)
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
// Tiny markdown-ish renderer for assistant prose. Intentional scope:
// **bold**, *italic*, # H1, ## H2, ### H3, * / - list items,
// blank-line paragraph breaks, `---` horizontal rule, [[cite:Source]] chip,
// [[icon:š”]] inline-icon prefix.
function renderMarkdown(src) {
if (!src) return '';
const lines = src.replace(/\r\n/g, '\n').split('\n');
const out = [];
let buf = [];
let inList = false;
let inOrdered = false;
const flushParagraph = () => {
if (!buf.length) return;
// Format each line through inline-markdown first (escaping happens there),
// then join with <br> so single-newline line breaks (e.g. inside a poem
// stanza or under a bold "Section:" header) are preserved. Real ChatGPT
// renders single newlines as soft breaks too.
const joined = buf.map(l => formatInline(l)).join('<br>').replace(/^(<br>)+|(<br>)+$/g, '');
if (joined) out.push(`<p>${joined}</p>`);
buf = [];
};
const flushList = () => {
if (inList) { out.push('</ul>'); inList = false; }
if (inOrdered) { out.push('</ol>'); inOrdered = false; }
};
for (let raw of lines) {
const line = raw.replace(/\s+$/, '');
if (!line.trim()) { flushParagraph(); flushList(); continue; }
// Horizontal rule
if (/^---+\s*$/.test(line)) { flushParagraph(); flushList(); out.push('<hr>'); continue; }
// Headings
const h = /^(#{1,3})\s+(.*)$/.exec(line);
if (h) {
flushParagraph(); flushList();
const level = h[1].length;
out.push(`<h${level}>${formatInline(h[2])}</h${level}>`);
continue;
}
// Bullet item
const li = /^[\*\-]\s+(.*)$/.exec(line);
if (li) {
flushParagraph();
if (inOrdered) { out.push('</ol>'); inOrdered = false; }
if (!inList) { out.push('<ul>'); inList = true; }
out.push(`<li>${formatInline(li[1])}</li>`);
continue;
}
// Ordered item
const oli = /^(\d+)\.\s+(.*)$/.exec(line);
if (oli) {
flushParagraph();
if (inList) { out.push('</ul>'); inList = false; }
if (!inOrdered) { out.push('<ol>'); inOrdered = true; }
out.push(`<li>${formatInline(oli[2])}</li>`);
continue;
}
// Bolded "Section title:" pattern ā make it visually a section header
const sec = /^\*\*(.+?)\*\*:?\s*$/.exec(line);
if (sec) {
flushParagraph(); flushList();
out.push(`<p class="section-title">${formatInline(sec[1])}</p>`);
continue;
}
buf.push(line);
}
flushParagraph(); flushList();
return out.join('\n');
}
function formatInline(s) {
let out = escapeHTML(s);
// Inline icon prefix (kept un-escaped because emoji is a glyph, not markup).
out = out.replace(/\[\[icon:(.+?)\]\]/g, (_, ico) => `<span class="icon-prefix">${ico}</span>`);
// Cite chip
out = out.replace(/\[\[cite:(.+?)\]\]/g, (_, c) => `<span class="cite">${c}</span>`);
// Bold **text**
out = out.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
// Italic *text* ā must come AFTER bold so we don't eat ** markers
out = out.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g, '$1<em>$2</em>');
return out;
}
// ---------------------------------------------------------------------------
// Header
// ---------------------------------------------------------------------------
function renderStatusBar(thread) {
const sb = thread.statusBar || {};
const time = sb.time || '9:41';
const dnd = sb.dnd === true; // moon glyph next to time
// Default: full cluster (signal + wifi + battery)
return `
<div class="status-bar">
<div class="time">${escapeHTML(time)} ${dnd ? ICONS.moonDND : ''}</div>
<div class="right-cluster">
${ICONS.signal}
${ICONS.wifi}
${ICONS.battery}
</div>
</div>
`;
}
function renderHeader(thread) {
const h = thread.header || {};
const style = h.style || 'model-tag'; // model-tag | title-only
const title = h.title || 'ChatGPT';
const model = h.model || ''; // e.g. "5.1"
const rightIcons = h.rightIcons || (style === 'title-only' ? ['edit'] : ['personPlus', 'dottedCircle']);
// Optional alternate right-icon set, faded-in by the driver when the chat
// transitions from "empty" to "active". Render both sets stacked when both
// are provided ā the driver toggles `data-active` between "primary"/"alt".
const rightIconsAlt = h.rightIconsAlt || null;
// Center cluster
let center = '';
if (style === 'title-only') {
// "ChatGPT >" hard-left actually but iOS centers ā match reference.
center = `<div class="center"><span>${escapeHTML(title)}</span><span class="chev-right">${ICONS.chevronRight}</span></div>`;
} else if (style === 'plain-title') {
center = `<div class="center"><span>${escapeHTML(title)}</span></div>`;
} else {
// model-tag default ā "ChatGPT 5.1 v"
center = `<div class="center"><span>${escapeHTML(title)}</span>${model ? `<span class="model-tag">${escapeHTML(model)}</span>` : ''}<span class="chev-down">${ICONS.chevronDown}</span></div>`;
}
const iconMap = {
personPlus: ICONS.personPlus,
dottedCircle: ICONS.dottedCircle,
edit: ICONS.editPencil,
more: ICONS.moreDots,
};
const renderCluster = (keys) => keys.map(k => iconMap[k] || '').join('');
const rightHTML = rightIconsAlt
? `<div class="cluster primary" data-cluster="primary">${renderCluster(rightIcons)}</div>
<div class="cluster alt" data-cluster="alt">${renderCluster(rightIconsAlt)}</div>`
: renderCluster(rightIcons);
const rightAttrs = rightIconsAlt ? ' data-active="primary"' : '';
return `
<div class="gpt-header ${style === 'title-only' ? 'title-center' : ''}">
<div class="left">
<div class="hamburger">${ICONS.hamburger}</div>
</div>
${center}
<div class="right"${rightAttrs}>${rightHTML}</div>
</div>
`;
}
// ---------------------------------------------------------------------------
// Messages
// ---------------------------------------------------------------------------
function animAttrs(msg) {
// In animation mode every row gets a stable id (assigned upstream) and may
// start in a hidden state. data-pending="1" hides via display:none in CSS.
const id = msg.id ? ` data-anim-id="${escapeHTML(msg.id)}"` : '';
const pending = msg.popState === 'pending' ? ' data-pending="1"' : '';
const animClass = msg.popState === 'pending' ? 'pop-pending'
: msg.popState === 'now' ? 'pop-now' : '';
return { id, pending, animClass };
}
function renderUserText(msg) {
const a = animAttrs(msg);
return `<div class="row user ${a.animClass}"${a.id}${a.pending}><div class="bubble">${escapeHTML(msg.text || '').replace(/\n/g, '<br>')}</div></div>`;
}
function renderUserImage(msg) {
const a = animAttrs(msg);
const src = msg.src || '';
const cls = msg.aspect === 'square' ? 'attachment square' : 'attachment';
return `<div class="row user-image ${a.animClass}"${a.id}${a.pending}><div class="${cls}"><img src="${escapeHTML(src)}" alt=""></div></div>`;
}
// Wrap visible text nodes in <span class="word" data-stream="0">word</span>
// without touching tags or already-wrapped content. Whitespace is preserved
// outside the spans so word gaps are real spaces (CSS doesn't have to fake
// them with padding).
function wrapWordsForStreaming(html) {
const out = [];
let i = 0;
while (i < html.length) {
if (html[i] === '<') {
// Pass tags through unchanged
const end = html.indexOf('>', i);
if (end === -1) { out.push(html.slice(i)); break; }
out.push(html.slice(i, end + 1));
i = end + 1;
continue;
}
// Read a text run up to the next tag
const nextTag = html.indexOf('<', i);
const run = nextTag === -1 ? html.slice(i) : html.slice(i, nextTag);
// Tokenize the run into words + whitespace
run.split(/(\s+)/).forEach(tok => {
if (!tok) return;
if (/^\s+$/.test(tok)) out.push(tok);
else out.push(`<span class="word" data-stream="0">${tok}</span>`);
});
i = nextTag === -1 ? html.length : nextTag;
}
return out.join('');
}
// Browser-rendered list markers (the bullet glyphs on `<li>`) can't be
// hidden by the word-stream wrapper because they're CSS-painted, not text.
// So when streaming, convert `<ul><li>X</li></ul>` to a div tree whose
// items begin with "⢠" as literal text ā that bullet then becomes a
// streamable word and arrives with its line.
function inlineListBulletsForStreaming(html) {
return html
.replace(/<ul[^>]*>/g, '<div class="md-list">')
.replace(/<\/ul>/g, '</div>')
.replace(/<ol[^>]*>/g, '<div class="md-list ordered">')
.replace(/<\/ol>/g, '</div>')
.replace(/<li>/g, '<div class="md-li">⢠')
.replace(/<\/li>/g, '</div>');
}
function renderAssistant(msg) {
const a = animAttrs(msg);
// Real ChatGPT renders the assistant title as plain bold text ā no spiral
// logo. (The logo only appears in the empty-state hero, not before each
// message.)
const titleRaw = msg.title
? `<div class="title-row"><span class="title-text">${escapeHTML(msg.title)}</span></div>`
: '';
let body = renderMarkdown(msg.text || '');
let title = titleRaw;
if (msg.stream === true) {
body = inlineListBulletsForStreaming(body);
body = wrapWordsForStreaming(body);
if (title) title = wrapWordsForStreaming(title);
}
const feedback = msg.feedback === false ? '' :
`<div class="feedback">${ICONS.thumbsUp}${ICONS.thumbsDown}</div>`;
const streamCls = msg.stream === true ? ' streaming-body' : '';
return `
<div class="row assistant ${a.animClass}"${a.id}${a.pending}>
${title}
<div class="assistant-body${streamCls}">${body}</div>
${feedback}
</div>
`;
}
function renderLoadingDot(msg) {
const a = animAttrs(msg);
return `<div class="row loading-dot ${a.animClass}"${a.id}${a.pending}><div class="dot"></div></div>`;
}
function renderEmptyState() {
return `<div class="empty-state"><div class="big-logo">${ICONS.openaiSpiral}</div></div>`;
}
// ---------------------------------------------------------------------------
// Composer
// ---------------------------------------------------------------------------
function renderComposer(thread) {
const c = thread.composer || {};
const placeholder = c.placeholder || 'Ask anything';
const hasText = c.text != null && c.text !== '';
const streaming = c.streaming === true;
const showCaret = c.cursor !== false && hasText;
const sendCls = streaming ? 'streaming' : (hasText ? 'active' : '');
const sendIcon = streaming ? ICONS.stopSquare : ICONS.sendArrow;
// Optional Apps-SDK GPT chip
if (c.chip) {
const name = c.chip.name || 'GPT';
return `
<div class="composer-wrap">
<div class="composer with-chip">
<div class="gpt-chip">
<span>${escapeHTML(name)}</span>
<span class="x">Ć</span>
</div>
<div class="input-row">
<div class="plus-btn">${ICONS.plus}</div>
<div class="input">${hasText ? `<span class="composer-text">${escapeHTML(c.text)}</span>` : `<span class="placeholder">${escapeHTML(placeholder)}</span>`}${showCaret ? '<span class="caret"></span>' : ''}</div>
<div class="mic-btn">${ICONS.mic}</div>
<div class="send-btn ${sendCls}">${sendIcon}</div>
</div>
</div>
</div>
`;
}
return `
<div class="composer-wrap">
<div class="composer">
<div class="plus-btn">${ICONS.plus}</div>
<div class="input">${hasText ? `<span class="composer-text">${escapeHTML(c.text)}</span>` : `<span class="placeholder">${escapeHTML(placeholder)}</span>`}${showCaret ? '<span class="caret"></span>' : ''}</div>
<div class="mic-btn">${ICONS.mic}</div>
<div class="send-btn ${sendCls}">${sendIcon}</div>
</div>
</div>
`;
}
// ---------------------------------------------------------------------------
// Main render
// ---------------------------------------------------------------------------
function loadCSS() {
return fs.readFileSync(path.join(__dirname, 'templates', 'chat.css'), 'utf-8');
}
function renderMessages(messages) {
return (messages || []).map(m => {
if (m.type === 'user-text') return renderUserText(m);
if (m.type === 'user-image') return renderUserImage(m);
if (m.type === 'assistant') return renderAssistant(m);
if (m.type === 'loading-dot') return renderLoadingDot(m);
return '';
}).join('\n');
}
function renderHTML(thread) {
const css = loadCSS();
const messages = thread.messages || [];
const hasMessages = messages.length > 0;
const inner = hasMessages
? `<div class="conversation">${renderMessages(messages)}</div>`
: renderEmptyState();
// Inline keyboard (no external atom). Same structure as the apple-notes
// mockup's .kbd block, scaled to fit a 750-wide stage. Driver toggles
// data-state and the stage's data-keyboard-shown to swap layouts.
const kbHTML = thread.keyboard ? renderKeyboard(thread.keyboard) : '';
const stageAttrs = thread.keyboard && thread.keyboard.state === 'shown'
? ' data-keyboard-shown="1"' : '';
return `<!DOCTYPE html>
<html><head><meta charset="utf-8"><style>${css}</style></head>
<body>
<div class="stage"${stageAttrs}>
${renderStatusBar(thread)}
${renderHeader(thread)}
${inner}
${renderComposer(thread)}
${kbHTML}
</div>
</body></html>`;
}
// Inline iOS QWERTY keyboard ā modeled on create-apple-notes-mockup's .kbd
// block. The chatgpt variant has no formatting toolbar (apple-notes' Aa /
// checklist / etc.) because the composer pill sits above instead.
function renderKeyboard(kb) {
if (!kb) return '';
const id = kb.id || 'kb';
const state = kb.state || 'hidden';
const upper = kb.shift === 'upper';
const ltr = c => upper ? c.toUpperCase() : c;
const r1 = (kb.letters_row1 || 'qwertyuiop').split('');
const r2 = (kb.letters_row2 || 'asdfghjkl').split('');
const r3 = (kb.letters_row3 || 'zxcvbnm').split('');
const sug = kb.suggestions || ['I', 'The', "I'm"];
return `
<div class="kbd" data-anim-id="${escapeHTML(id)}" data-state="${escapeHTML(state)}">
<div class="kbd-suggestions">
${sug.map(s => `<div class="kbd-suggestion">${escapeHTML(s)}</div>`).join('')}
</div>
<div class="kbd-row">
${r1.map(c => `<div class="kbd-key">${escapeHTML(ltr(c))}</div>`).join('')}
</div>
<div class="kbd-row kbd-row--abc">
${r2.map(c => `<div class="kbd-key">${escapeHTML(ltr(c))}</div>`).join('')}
</div>
<div class="kbd-row kbd-row--zxc">
<div class="kbd-key kbd-key--wide">${ICONS.kbdShift || 'ā§'}</div>
${r3.map(c => `<div class="kbd-key">${escapeHTML(ltr(c))}</div>`).join('')}
<div class="kbd-key kbd-key--wide">${ICONS.kbdBackspace || 'ā«'}</div>
</div>
<div class="kbd-bottom">
<div class="kbd-key kbd-key--num">123</div>
<div class="kbd-key kbd-key--emoji">${ICONS.kbdEmoji || 'ā»'}</div>
<div class="kbd-key kbd-key--space">space</div>
<div class="kbd-key kbd-key--return">${ICONS.kbdReturn || 'ā'}</div>
</div>
<div class="kbd-footer">
${ICONS.kbdGlobe || ''}
${ICONS.kbdMic || ''}
</div>
</div>
`;
}
function parseArgs(argv) {
const args = {};
for (let i = 2; i < argv.length; i++) {
if (argv[i] === '--thread') args.thread = argv[++i];
else if (argv[i] === '--out') args.out = argv[++i];
}
return args;
}
function main() {
const args = parseArgs(process.argv);
if (!args.thread || !args.out) {
console.error('Usage: node generate.js --thread path.json --out path.html');
process.exit(1);
}
const thread = JSON.parse(fs.readFileSync(args.thread, 'utf-8'));
const html = renderHTML(thread);
fs.mkdirSync(path.dirname(args.out), { recursive: true });
fs.writeFileSync(args.out, html);
console.log(`Wrote ${args.out}`);
}
if (require.main === module) main();
module.exports = { renderHTML };
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |