ttmouse/dsh-generative-ui ↗★ 0

@ttmouse/dsh-generative-ui

dsh-generative-ui:让 AI 在 DSH 对话流里直接输出可交互的 HTML 组件(Generative UI)。agent 在回复里写 ```generative-ui 围栏(内容为自包含 HTML),客户端把每轮回答里的工件提取出来,沙箱渲染成内嵌的可交互 UI。纯客户端实现,零后端、零存储——工件就活在消息文本里,会话在它就在。 适合希望 AI 回复能够直接呈现并运行交互式网页工件的用户。

Package
@ttmouse/dsh-generative-ui
Compatibility
Unverified
Version
0.1.0
License
MIT
Last updated
Oct 10, 2026

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:ttmouse/dsh-generative-ui

Two generative-ui cards rendered inline in a DSH chat: a counter and a BMI calculator

English | 简体中文

dsh-generative-ui

Let the AI output interactive HTML components (Generative UI) directly in the DSH chat flow.

The agent writes a fenced code block in its reply:

```generative-ui

+1 0
let n=0;plus.onclick=()=>{n++;n.textContent=n}
```

The plugin extracts every artifact from that turn and renders it as a sandboxed card below the message: an `` (no same-origin) — the artifact is fully interactive, but can never touch the host page, cookies, or local storage.

Design

  • Pure client-side: no backend, no storage. Artifacts live in the session message text — the session is the store; there is no second copy of state and nothing to sync.
  • The host half does one thing: broadcast the fenced-block convention to every agent via systemPrompt.section.
  • The browser half uses a uiConversation.events accumulator to extract artifacts from assistant/message events (the same turn-accumulator pattern as dsh-taskboard), projects them onto the turn location, and renders the cards through the conversation.chat.turnTail slot.
  • Adaptive height: a bootstrap injected into each artifact reports its height to the parent via ResizeObserver + postMessage; cards are clamped between 120–600px and scroll internally beyond that.

Install

dsh plugin --profile desktop add link:
# and add @ttmouse/dsh-generative-ui to dsh.profile.bundles in the profile
# package.json; restart the desktop app (the host half registers the prompt
# section; client.js is read from disk per request)

Develop

npm install && npm run build       # produces lib/client.js + lib/index.mjs
npm test                           # unit + e2e (headless Chromium)
npm run screenshot                 # regenerate screenshot.png from the real client

Client changes take effect on page refresh; host-half changes (the system-prompt text) need an app restart.

License

MIT