Cast content into a visible form. Content goes in, PNG comes out. The mold determines the shape.
Parameters
| Parameter | Description | Default value |
|---|---|---|
--design |
Specify design system (skip candidate preview) | Empty (enter preview flow) |
--dpr |
Device pixel ratio | 2 (4K quality) |
--author |
Signature text | Kenny Wu |
--photo |
Signature avatar URL/path | assets/avatar.png |
Execution flow
Step 0: Render routing
Determine whether the current content can use CLI fast rendering.
CLI-eligible modes: big, long, whiteboard, poster AI-only modes: infograph, comic, sketchnote (require creative layout, cannot be schema-ized)
Decision logic:
- If mode is infograph / comic / sketchnote → go directly to AI flow (Step 1)
- If mode is big / long / whiteboard / poster:
- Evaluate whether the content structure can fit into the corresponding mode's schema (see
schemas/{mode}.json) - Content structure is clear (has title, distinct paragraphs, linear reasoning chain) → CLI path
- Content is too complex (nested references, multi-column comparison, special layout requirements, uncertain it can fit) → AI path
- Evaluate whether the content structure can fit into the corresponding mode's schema (see
CLI path:
- Extract structured JSON from the content, conforming to the corresponding mode's schema
- Write to
/tmp/cast_input.json - Call:
node scripts/cast.js --input /tmp/cast_input.json --output ~/Downloads/{name}.png
- CLI succeeds → jump to Step 7 delivery (skip Steps 1-6)
- CLI fails → report the error, fall back to the full AI flow (continue to Step 1)
JSON schema structure(full definition for each mode see schemas/ directory):
big: { mode, phrase, design?, accent_words?, ghost_char?, attribution? }
long: { mode, title, body: [{type, text, ...}], design?, kicker?, subtitle?, theme? }
whiteboard: { mode, title, steps: [{type, ...}], design?, subtitle?, accent_words? }
poster: { mode, title, cards: [{body: [{type, ...}]}], design?, subtitle? }
Step 0.5: Read the basics
The following files must be read before starting:
Must read:
references/taste.md— taste baseline (anti-AI aesthetics + paper-print feel)references/design-index.md— index of 22 design systems
Read as needed by content type(determine which are needed after Step 1 analysis):
3. references/mode-infograph.md — infographic content theory (three-dimensional analysis of density/structure/emotion, 90/8/2 color rule, layout generation principles)
4. references/mode-long.md — long-form content rules (punchline detection, tone perception, paragraph preprocessing)
5. references/mode-big.md — large-type poster layout (dynamic font size calculation from character count, manual line-breaking principles)
6. references/mode-sketchnote.md — narrative structure (six rules against translationese, problem→failure→epiphany arc)
7. references/mode-whiteboard.md — whiteboard reasoning (logic chain extraction, 4 structural routes)
8. references/mode-poster.md — multi-card splitting (visual weight calculation, greedy splitting algorithm)
9. references/mode-comic.md — comic narrative (conflict extraction, storyboard system, 5 style routes)
Step 1: Acquire + analyze content
Acquire: URL → WebFetch / pasted text → use directly / file path → Read
Analyze: extract the content's three-dimensional features (see references/mode-infograph.md)
标题:[≤ 15 字]
副标题:[一句话 ≤ 30 字]
来源:[可选]
密度:[稀 ≤50字 / 中 50-200 / 密 200+]
结构:[单点 / 对比 / 层级 / 流程 / 辐射 / 并列]
情绪:[沉思 / 锐利 / 温暖 / 技术]
主题标签:[2-5 个关键词]
Content preprocessing(follow ljg-card specification):
- Punchline detection: standalone paragraphs <25 characters containing core insight, mark as highlight
- Paragraph segmentation: split by semantic completeness, not mechanically by fixed character count
- Data cleaning: ensure numbers feel real (
47.2%instead of50%,+1 (312) 847-1928instead of1234567) - Copy de-AI-ification: prohibit typical AI wording such as "empower/seamless/unleash/next-generation/deeply empower" (full list see
references/taste.mdSection 5) - Anti-translationese: prohibit "is…" / "in the process of…" / "perform + noun" (see the complete rules in
references/mode-sketchnote.mdSix Axioms)
Step 2: Match candidates
Comic mode skips this step: comic mode uses a fixed black-and-white palette; the design system's color tokens do not apply. Go directly to Step 4; the comic style is determined by the 5 routes of references/mode-comic.md (Katsuhiro Otomo/Takehiko Inoue/Kentaro Miura/Taiyo Matsumoto/Jiro Taniguchi), selected during Step 4 rendering based on the content's tone.
Select 3-5 candidate design systems from design-index.md.
Matching logic:
- Emotion→visual style:
- Contemplative → minimal-clean / editorial-warm / dark-premium
- Sharp → dark-minimal / high-contrast / vibrant
- Warm → editorial-warm / organic-warm / playful
- Technical → technical-data / monospace / dark-minimal
- Thematic relevance: add points when the content domain overlaps with the brand domain (e.g., AI content→AI brand, finance→fintech)
- Density fit: sparse→whitespace-heavy styles (apple, notion), dense→data-dense styles (stripe, ibm)
- Visual diversity: candidates should be visually distinct from one another. If all 3 are dark-minimal, swap one for editorial-warm
Output the candidate list, each with a one-sentence matching rationale.
Step 3: Candidate confirmation
Display the candidate list in the terminal, each with a one-sentence matching rationale and palette information:
候选设计系统:
1. linear — 精密暗色,适合技术架构内容 (Canvas: #010102, Accent: #5e6ad2)
2. claude — 温暖编辑风,适合人文思考 (Canvas: #faf9f5, Accent: #cc785c)
3. stripe — 数据密集,适合金融展示 (Canvas: #ffffff, Accent: #533afd)
4. notion — 简约留白,适合知识管理 (Canvas: #ffffff, Accent: #5645d4)
Tell the user: choose a number (e.g., "use 2"), or say "show another batch" to get new recommendations. After the user confirms, proceed to Step 4.
Step 4: Render
Based on the mode determined in Step 1, select the corresponding template:
| Mode | Template file |
|---|---|
| infograph | assets/infograph_template.html |
| big | assets/big_template.html |
| long | assets/long_template.html |
| whiteboard | assets/whiteboard_template.html |
| poster | assets/poster_template.html |
| comic | assets/comic_template.html |
| sketchnote | assets/sketchnote_template.html |
After the user selects:
- Read the compact design file:
references/designs/{name}.mdljg-*No file read is needed for tones; use the CSS variables in design-index.md directly
- Read
references/taste.md(paper-print baseline) - Read the corresponding template file
- Map design tokens to template CSS variables:
| Template variable | Design system source |
|---|---|
--bg |
canvas color (overlaid with paper grain texture) |
--green(structural color) |
hairline / surface-2 color |
--pink(pop color) |
accent / primary color |
--ink |
ink primary text color (desaturate 10-20% to simulate printing) |
--ink-light |
ink-muted color |
Fonts are not in this table—they are fixed by mode, see references/taste.md Section 2.
Font sizes and typography follow ljg-card, not the brand design system. The brand design system only provides color and visual atmosphere references (palette, shadow philosophy, corner style, whitespace rhythm). Font size rules strictly follow ljg-card's mobile-first standards: body text ≥36px, annotations ≥24px. Element ratios are graded by mode: big≥10:1, infograph≥6:1, comic≥8:1, sketchnote≥5:1, long/poster/whiteboard≥4:1 (see references/taste.md)。
Paper-print feel: all output should follow the paper aesthetic requirements of references/taste.md Section 6—warm paper background color, ink-like text, desaturated accent colors, ultra-thin hairline borders, looking like print rather than a webpage screenshot.
- Design the visual based on content analysis (density/structure/anchors), following the same principles as the ljg-card infographic mode
- Replace the placeholders in the template (see the comment at the top of each template file for that template's placeholders)
- Write to
/tmp/cast_{name}.html
poster mode special case: each card is written independently, with a sequence number in the filename /tmp/cast_{name}_{N}.html。
Multi-card batch consistency: when the content needs to be split into multiple images (infographic series, multi-card poster, user requests "multiple images"), the following batch rules must be followed:
-
Token locking: before rendering the first card, output a shared CSS variable table used by all cards. The variable table includes:
- Colors:
--bg,--green,--pink,--ink,--ink-light(from the Step 4 design token mapping) - Font size scale: heading size / section heading size / body size / caption size (from
taste.mdthe mode rules in section 2) - Spacing rhythm: content margins, block spacing, colophon height
- Font stack: determined by mode, consistent across the whole batch
- Colors:
-
Token locking output format(written before the HTML of all cards):
批次 Token: --bg: #faf6f0; --green: #e8dfd2; --pink: #d97757; --ink: #2c2418; --ink-light: #7a6f5f 标题: 140px serif | 段落标题: 48px zh-serif | 正文: 36px zh-serif | 标注: 24px mono 边距: 60px | 区块间距: 40px | 圆角: 6px -
Each card's
{{CUSTOM_CSS}}must begin by copying the CSS variable declarations from the Token locking table(:root { ... }), and only then write that card's unique layout CSS. This ensures that even if a card's HTML is opened on its own, the visual result is complete. -
No cross-card drift: between different cards, elements at the same semantic level must use the same font size. For example, if card 1's body text is 36px, card 2's body text must also be 36px. Only the layout structure (grid, flex, positioning) may vary depending on the content.
Signature parameters:--author replaces the footer left-side text,--photo serves as the footer avatar. When not specified, the default signature is Kenny Wu, and the default avatar is the absolute path of assets/avatar.png .
Step 5: Self-check
- Does the visual form grow out of the content? If the content were changed, would this layout still hold up?
- Is the design system's brand language perceptible in the image (not just a swapped color palette, but the typographic rhythm also matches)?
- Do element proportions meet the mode's minimum standard? (big≥10:1, infograph≥6:1, comic≥8:1, sketchnote≥5:1, others≥4:1)
- Do accent colors comply with the brand type rules? (standard colors ≤2 places, weak accent ≤3 visually prominent points)
- Is body text ≥36px, and captions ≥24px?
- Multi-card mode: does each card cover only one chapter/topic? Is content on different topics kept off the same card?
- Batch consistency (for multiple cards): do all cards' color variables, font size scale, and spacing rhythm strictly match the Token locking table? Are the font sizes for the same semantic level (body, heading, caption) exactly identical?
- Would someone telling people "AI made this" be seen through at a glance?
Step 6: Screenshot (4K)
The template CSS width is 1080px. The width parameter of capture4k.js is the viewport width (not the output width). The DPR parameter controls the output resolution.
node assets/capture4k.js /tmp/cast_{name}.html ~/Downloads/{name}.png 1080 800 2 fullpage
Parameter description:1080 = viewport width (matching the template),800 = initial height (automatically expanded in fullpage mode),2 = DPR (outputs 2160px wide),fullpage = capture the full content height.
Multi-card batch: All cards in the same batch must use exactly the same capture command parameters to ensure consistent output width and DPR.
Step 7: Deliver
Report the file paths.
Refinement
- "Switch to a different design system" → go back to Step 3
- "Adjust the color scheme" → fine-tune the CSS variables, keeping the same design system
- "Change the layout" → redesign, same design system
Quick mode (specified via --design)
When the user specifies a design system via --design , skip Step 3 and go directly to Step 4.
For available names, see the directory names under references/design-index.md .