Agent Skills
› KunAgent/Kun
› gen-ui
gen-ui
GitHub用于在对话中构建并渲染交互式HTML小部件,如模拟器、计算器或UI原型,通过render_widget工具展示动态可视化内容。
触发场景
需要参数探索或模拟演示
生成算法逐步执行演示
创建交互式图表或计算器
制作UI原型或线框图
安装
npx skills add KunAgent/Kun --skill gen-ui -g -y
SKILL.md
Frontmatter
{
"name": "gen-ui",
"description": "Build interactive HTML widgets (simulators, explorers, calculators, UI mockups) inline in desktop conversations with render_widget."
}
Interactive Widgets (Gen UI)
Copyright (c) 2026 KunAgent. Licensed under the MIT License.
Use render_widget to show a small interactive page inside the current desktop conversation. It is available only when the tool is advertised for this turn.
When to build a widget
- Build one when seeing or manipulating something makes the answer clearer: parameter explorers ("what happens when…"), simulations, algorithm step-throughs, interactive charts, calculators, timelines, or UI mockups with alternatives.
- Do not build one for a plain table (answer in Markdown), a static structure (Mermaid code block), a simple governed chart (
render_chartwhen advertised), or decoration. - A request for a website, app page, component, or any project change is project work: edit the workspace instead of rendering a widget.
Output contract
- Call
render_widgetwithtitle(short, user facing) andhtml(an HTML fragment). Usepathinstead ofhtmlonly to re-render an existing.htmlfile in the workspace. - Write a fragment: markup plus optional
<style>and<script>. No<!doctype>,<html>,<head>or<body>. - Give the root element a unique id and query it with
document.getElementById. Never depend ondocument.currentScript. - Keep it under 1 MB. Aggregate, sample, or round large data instead of inlining raw rows.
- Use
mode: "wide"only for a full desktop application mockup or panels that must stay side by side. Everything else uses the default inline mode. - Do not use
fetch, XHR, WebSocket, forms that submit,window.open, or browser storage for important data. The page has no network access except static libraries. - After the tool call, reply with at most a short conclusion. Never describe the HTML, announce a widget, or repeat the data shown in it.
Libraries
- Bundled and offline:
https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js,https://cdn.jsdelivr.net/npm/echarts@5.6.0/dist/echarts.min.js,https://cdn.jsdelivr.net/npm/lucide@0.544.0/dist/umd/lucide.min.js. Use these exact URLs in a literal<script src="…">. - Other files may load from cdn.jsdelivr.net, cdnjs.cloudflare.com, unpkg.com or esm.sh when the user is online. Prefer plain SVG, Canvas and DOM for small visuals.
Styling
- The page background is transparent and follows Kun's light or dark theme. Use the theme variables instead of fixed colors:
--foreground,--muted-foreground,--card,--muted,--border,--brand,--destructive,--success,--warning, and--viz-series-1…--viz-series-6for data series. - Base classes are available:
.card,.stack,.row,.grid-2,.grid-3,.btn,.btn-primary,.badge,.form-label,.text-muted,.text-small,.tabular-nums,.viz-dotted-background. Form controls, tables and SVG text already follow the theme. - Keep text readable: secondary text uses
--muted-foreground, never lighter. Use one accent for the primary measure; add series colors only for real categories. - For product mockups, define the product's own colors and type at the mockup root (use
light-dark()when it should follow the theme) instead of the widget classes, and frame small mockups on.viz-dotted-background. - Charts: label axes with quantities and units, size SVGs from their container width (redraw on
ResizeObserver), and keep labels at 11px or larger.
Composition
- Choose the smallest composition that answers the question: a compact control row, one dominant visual, and at most one line of live detail.
- Show live values next to the control that changes them. Add only the controls the user needs; do not invent search, filter or reset UI.
- For UI alternatives, show two or three distinct variants (tabs or a small carousel) rather than one.
State and follow-ups
window.kun.widgetStateis the last saved snapshot ({ modelContent, privateContent }) ornull. Restore from it on load and on thekun:set_globalswindow event.- After a meaningful interaction, call
window.kun.setWidgetState({ modelContent, privateContent }).catch(() => {}). The snapshot is at most 16 KiB.modelContentholds choices the user may ask about next (it is attached to their next message);privateContentholds view details worth restoring. Never save on load. - For drill-down actions, add a clearly labeled button whose click handler calls
await window.kun.sendFollowUpMessage({ prompt, title })with the selected values in the prompt. The user may be asked to confirm. - Links: use normal
<a href="https://…">anchors, or callwindow.kun.openExternal({ href })from a click handler. Only http(s) URLs open.
Quality check before calling the tool
- Every queried element exists, no undefined identifiers, and the main interaction updates the visual.
- Text is legible in both light and dark themes, nothing overflows at a 360px width, and numbers that change use
.tabular-nums.
版本历史
- 0d84061 当前 2026-11-02 18:22


