Training Poster Generator (Local Render) · 🌐 中文
Renders structured training information into a vertical tech-style poster PNG. Does not rely on Feishu runtime, requires no login, and needs no network interface; it simply starts a temporary static service locally and captures a screenshot using a headless browser.
Default Behavior (Important)
When users say "Generate a training poster," "Make a training poster," or "Open the poster workspace," default to opening the Web UI — do not call render_poster, and do not ask for parameters first.
Startup flow (always use the same entry point; idempotent):
- Windows:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/bootstrap.ps1 - macOS / Linux:
bash scripts/bootstrap.sh
The script detects Node.js (downloads a portable version to .runtime/ if missing) → starts the workspace → returns { ok, url }. Open the url for the user; if it cannot be opened, send them the link.
Only use render_poster / render.mjs when users explicitly request "batch / no interface needed / give me the image directly / generate N images."
What It Can Do
- Open full Web UI:
npm run ui(ornode scripts/open-ui.mjs) starts the service in the background and returns a URL; users can select templates/colors, fill forms, crop photos, preview in real-time, and export PNG. This is the preferred method when manual adjustments are needed. - Input JSON → Output PNG:
node scripts/render.mjs --data job.json --out poster.png(for batch/headless usage) - Instructor photos, QR codes: pass local image paths directly; the script automatically converts them to dataURLs.
- Automatically convert Beijing time to Europe Central, US West, and US East timezones with DST/Standard time annotations.
- Three color schemes: built-in deep blue tech (default), color extraction from a reference image, manual primary/accent color specification.
- Interactive Web UI for humans:
node scripts/preview.mjs - MCP server:
node scripts/mcp.mjs(can be mounted directly by Claude Desktop / Cursor / DSH, etc.)
Integration Methods
- Command-capable agents: Run
bootstrap.ps1/bootstrap.shfirst and give the workspace URL to the user; only runrender.mjsfor batch/headless. - MCP-compatible clients: Use
open_editorto open the workspace,render_posterfor batch output (see end of document). SKILL.md-compatible runtimes (DSH / Claude Code, etc.): Place the entire directory into the skills directory.
When to Open the Workspace
| User Intent | Action |
|---|---|
| Wants to pick templates, change colors, preview, fine-tune | open_editor / open-ui.mjs, give URL to user |
| Batch, scheduled, headless output | render_poster / render.mjs |
| Only asks "can it be done / how to use" | Explain both methods; recommend opening the workspace by default |
After opening the workspace, do not call render_poster to generate images on behalf of the user, and do not modify 培训海报生成器 Training Poster Generator.html; wait for the user to export.
Privacy
- No accounts, no databases; form content, photos, and QR codes are processed only in local memory and the temporary
127.0.0.1service. - The build artifact has removed all Feishu-injected Slardar / Tea / performance monitoring scripts and adds CSP headers to block external resources and external connections.
- No remote fonts are requested; system fonts are used;
http(s)external image links are rejected and written intowarnings. - Opening the workspace does not require internet; only the first
bootstrapdownloads a portable Node.js version if missing, andnpm installdownloads playwright-core.
Prerequisites
- Node.js ≥ 20: Not required to be pre-installed; the first
bootstraprun downloads a portable version to.runtime/if missing. - Opening the workspace only needs a system browser (Edge/Chrome/Safari).
- Batch output / MCP
render_posteronly requiresnpm install(playwright-core) and Edge/Chrome.
First Use (Someone Else's Computer)
# Windows
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/bootstrap.ps1
# macOS / Linux
bash scripts/bootstrap.sh
Process: Detect Node → if missing, download portable version (≈ 35 MB, no system installation) → start workspace → output { ok, url, pid }.
Give the url to the user's browser / WorkBuddy preview panel.
Self-Check
npm install # Only needed for batch output / MCP
node scripts/doctor.mjs # Environment check: Node / app / playwright-core / browser
node scripts/doctor.mjs --render # Also renders a real self-check image
node scripts/test.mjs # End-to-end: render sample + MCP handshake
node scripts/audit.mjs # Privacy: no monitoring scripts, no successful external network requests
All output JSON; ok: true indicates availability; on failure, checks indicates which item is missing.
Quick Start
# 1. Open workspace (preferred when manual adjustment is needed)
npm run ui
# 2. Render sample (batch/headless)
node scripts/render.mjs --data templates/example.json --out out/poster.png
# 2. Inline JSON (suitable for one-time agent calls)
node scripts/render.mjs --json '{"form":{"topic":"Understand the Customer","trainingDate":"2026-12-16","timeBeijing":"19:00","timeBeijingEnd":"20:00"}}' --out out/poster.png
# 3. 3x resolution
node scripts/render.mjs --data job.json --out poster.png --scale 3
# 4. Open interactive workspace (form on left, preview on right, export PNG)
node scripts/preview.mjs --port 4173
The script outputs JSON to stdout:
{
"ok": true,
"out": "E:\\...\\poster.png",
"width": 1500,
"height": 2740,
"cssWidth": 750,
"cssHeight": 1370,
"scale": 2,
"bytes": 1657563,
"browser": "channel:msedge",
"warnings": ["No qrcodeImage provided; poster shows \"QR code pending upload\" placeholder at bottom right"]
}
On failure, outputs { "ok": false, "error": "..." } and exits with code 1.
Input Format
{
"form": {
"seriesName": "Product Operations Training Camp - Session 18",
"topic": "Tell the Business Story with Data",
"courseFormat": "Online Training",
"instructorName": "Lin Xiao",
"instructorBio": "Product Operations Department",
"instructorPhoto": "C:/photos/liming.jpg",
"highlights": ["Master key methods for client communication", "Streamline cross-department collaboration processes"],
"targetAudience": "All frontline operations colleagues",
"trainingDate": "2026-12-16",
"timeBeijing": "19:00",
"timeBeijingEnd": "20:00",
"includeEuropeTime": true,
"qrcodeImage": "C:/photos/qr.png"
},
"template": { "mode": "blue" }
}
form Fields
| Field | Type | Required | Description |
|---|---|---|---|
topic | string | Yes | Main title; recommended 10–20 characters; long titles wrap, increasing poster height |
seriesName | string | No | Series name at top, e.g., "Product Operations Training Camp - Session 18" |
courseFormat | string | No | Online Training (default) / In-Person Training |
trainingLocation | string | Required for in-person | Displayed at bottom right (replaces QR code) for in-person training |
instructorName | string | No | Instructor's name |
instructorBio | string | No | Instructor's bio/department |
instructorPhoto | string | No | Local path or dataURL (no external links); leave blank for built-in silhouette |
highlights | string[] | No | One card per item; recommended 2–4 items, each ≤ 30 characters |
targetAudience | string | No | Suitable audience |
trainingDate | string | No | YYYY-MM-DD; displayed as "M month D day" and used for timezone conversion |
timeBeijing | string | No | HH:mm, Beijing start time |
timeBeijingEnd | string | No | HH:mm, Beijing end time |
includeEuropeTime | boolean | No | Default true, shows Europe Central time |
includeUsWestTime | boolean | No | Default false, shows US West time |
includeUsEastTime | boolean | No | Default false, shows US East time |
qrcodeImage | string | No | Local path or dataURL (no external links); for online training, leave blank to show placeholder |
signupLink | string | No | Used for promotional copy only, does not appear on poster |
template Fields (Optional)
{"mode":"blue"}: Built-in deep blue tech color scheme (default){"mode":"manual","manualStyle":{"primaryColor":"#1A2F4A","secondaryColor":"#45E2EA"}}: Manual color scheme{"mode":"custom","style":{...}}: Color scheme identified from a reference image (stylestructure same as above)
Relative path resolution for image fields: when using --data job.json, paths are resolved relative to the directory containing job.json; when using --json or inline calls, they are resolved relative to the current working directory. For Windows paths, use forward slashes C:/photos/a.jpg to avoid JSON escaping issues.
Rules & Limitations
- Maximum 2 additional timezones; priority order: Europe Central → US West → US East
- When
courseFormat=In-Person Training,trainingLocationis required; otherwise, an error is returned. - Poster width is fixed at 750px; height varies with content (approximately 1100–1700px), not fixed 9:16; for a fixed aspect ratio, crop or add padding manually.
- Fonts use system fonts (PingFang SC / Microsoft YaHei); no external font requests are made; font rendering may vary slightly by system.
- Output is PNG with no transparent background; if the extension is not
.png, only a warning is given; the content is still PNG. - Images only support local paths or dataURLs;
http(s)external links are rejected and written intowarnings. - If an image path does not exist or the format is unsupported, no error is thrown; it is treated as "not provided" and written into
warnings.
Common Errors
| Error | Resolution |
|---|---|
Missing required field form.topic | Add topic |
trainingLocation must be provided when courseFormat is "In-Person Training" | Add location, or change to online training |
ERR_MODULE_NOT_FOUND: playwright-core | Run npm install in the skill directory |
No available browser | Install Edge/Chrome; or set POSTER_BROWSER, pass --browser to specify path |
| Image becomes text path | Path does not exist, format unsupported, or external link used; check warnings and use local file |
MCP (Optional)
node scripts/mcp.mjs
Provides five tools:
open_editor({ port?, host? }): Starts the full Web UI, returnsurl/pid; use this when manual adjustment is neededclose_editor(): Closes the workspaceeditor_status(): Checks if the workspace is runningrender_poster({ job, out?, scale? }): Batch output; omitoutto write to system temp directorydescribe_poster_fields(): Returns field descriptions
open_editor requires the MCP client and tool to be on the same machine; cloud clients cannot access the returned 127.0.0.1 address.
In MCP-compatible clients, configure as a stdio server (use absolute paths for args):
{
"mcpServers": {
"training-poster": {
"command": "node",
"args": ["<absolute path to skill directory>/scripts/mcp.mjs"]
}
}
}
If the client cannot find node on Windows, replace command with the absolute path of node.exe.
Directory
SKILL.md This documentation
SKILL.en.md English documentation
培训海报生成器 Training Poster Generator.html Single-file web app (double-click to use; server renders via /#/render)
training-poster-generator-en.html English interface (also single file)
lib/index-file.mjs Locates the Chinese interface file (backward compatibility)
lib/server.mjs Single-file static server (exposes /__job.json, /__health)
lib/open-browser.mjs Opens a URL with the system browser
lib/ui.mjs Workspace start/reuse/close
lib/browser.mjs Cross-platform Edge/Chrome detection
lib/render-poster.mjs Rendering core (validation + screenshot + PNG size check)
scripts/render.mjs CLI: JSON -> PNG
scripts/bootstrap.ps1 Windows one-click first time: detect/download Node + start workspace
scripts/bootstrap.sh macOS/Linux one-click first time
scripts/preview.mjs Start Web UI in foreground (blocking)
scripts/open-ui.mjs Start workspace in background and return URL
scripts/close-ui.mjs Close workspace
scripts/status-ui.mjs Check workspace status
scripts/mcp.mjs MCP stdio server
scripts/doctor.mjs Environment self-check
scripts/test.mjs End-to-end self-test
scripts/audit.mjs Privacy self-check (no external scripts / no successful external requests)
使用说明 Read Me.txt Quick start guide for both usage methods
USAGE.md Usage guide (including WorkBuddy integration)
templates/example.json Runnable example
templates/fields.json Field descriptions
The UI is a single-file build (Vite standalone, hash routing). To change the layout, regenerate 培训海报生成器 Training Poster Generator.html from the original Feishu source code.