Skip to main content

headless-mode

Run playground without visible UI using SDK methods directly. Load this skill when building Markdown compilers, code formatters, or tools that need compiled output without display.

소스 정보

저장소
live-codes/livecodes
최근 소스 활동
2026년 9월 14일 12:04
감지된 SKILL.md 언어
영어
스타
1,527
포크
274

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
headless-mode
description
Run playground without visible UI using SDK methods directly. Load this skill when building Markdown compilers, code formatters, or tools that need compiled output without display.
metadata
{"type":"core","library":"livecodes","library_version":"0.13.0"}
requires
["sdk-embedding","sdk-methods"]
sources
["live-codes/livecodes:docs/docs/sdk/headless.mdx"]
This skill builds on sdk-embedding and sdk-methods. Read them first for foundational concepts. # LiveCodes — Headless Mode Headless mode runs LiveCodes without any visible UI. Use SDK methods to compile code, get output, and react to events. ## Setup ```javascript import { createPlayground } from 'livecodes'; // Create headless playground - container is optional const playground = await createPlayground({ headless: true, config: { markup: { language: 'markdown', content: '# Hello World' }, }, }); // Use SDK methods const code = await playground.getCode(); console.log(code.markup.compiled); // "<h1>Hello World</h1>" console.log(code.result); // Result page HTML ``` ## Core Patterns ### Markdown compiler ```javascript import { createPlayground } from 'livecodes'; let playground; async function compileMarkdown(markdown) { if (!playground) { playground = await createPlayground({ headless: true, config: { autoupdate: false }, }); } await playground.setConfig({ markup: { language: 'markdown', content: markdown }, }); const code = await playground.getCode(); return code.markup.compiled; } // Usage const html = await compileMarkdown('# Hello\n\nWorld'); console.log(html); // "<h1>Hello</h1>\n<p>World</p>" ``` ### React/JSX compiler ```javascript import { createPlayground } from 'livecodes'; let playground; async function compileJSX(jsxCode) { if (!playground) { playground = await createPlayground({ headless: true, config: { autoupdate: false }, }); } await playground.setConfig({ script: { language: 'react', content: jsxCode }, }); const code = await playground.getCode(); return code.script.compiled; } const compiled = await compileJSX(` function App() { return <h1>Hello</h1>; } `); ``` ### Python interpreter ```javascript import { createPlayground } from 'livecodes'; let playground; async function runPython(code) { if (!playground) { playground = await createPlayground({ headless: true, config: { autoupdate: true }, }); } // Set up console listener before running const outputs = []; playground.watch('console', ({ method, args }) => { outputs.push({ method, args }); }); await playground.setConfig({ script: { language: 'python', content: code }, }); // Python runs automatically with autoupdate: true // Or: await playground.run(); return outputs; } // Usage const outputs = await runPython('print("Hello from Python!")'); // [{ method: 'log', args: ['Hello from Python!'] }] ``` ### Get result HTML ```javascript async function getResultHTML(config) { const playground = await createPlayground({ headless: true, config: { ...config, autoupdate: false }, }); await playground.setConfig(config); const code = await playground.getCode(); return code.result; // Result page HTML } ``` ### Watch for changes ```javascript const playground = await createPlayground({ headless: true, config: { autoupdate: false }, }); // Watch for compiled code changes playground.watch('code', ({ code, config }) => { console.log('Compiled:', code.script.compiled); }); // Change config - watch callback fires await playground.setConfig({ script: { language: 'typescript', content: 'const x: number = 1;' }, }); ``` ## Common Mistakes ## Headless vs Visible Mode | Aspect | Visible | Headless | | --------- | ---------------- | ------------------------ | | Container | Required | Optional | | UI | Shown | Hidden | | Use case | User interaction | Programmatic compilation | ## When to Use Headless - **Markdown/MDX compiler** — Get compiled HTML without display - **Code formatter** — Use Prettier via LiveCodes - **Language transpiler** — TypeScript → JavaScript, SCSS → CSS - **Testing pipelines** — Run and verify code programmatically - **Python/Ruby/Go interpreter** — Execute WASM languages and capture output
GitHub에서 보기