dsh-genui README

项目的 README,来自 github.com/omdsh-dev/dsh-genui。合并为一个 markdown 文件:README.md。

GenUI for DeepSeek Harness

Generative UI for DeepSeek Harness (DSH)
Interactive, rich components rendered inline alongside the model's textual responses.

npm version DSH Compatibility License: MIT TypeScript Topic: dsh-plugin

English · 简体中文

🌐 Live Product Site · 🎬 Real Demo · 🚀 Quick Start · 🧩 Feature Matrix · 📖 Component Syntax (SKILL.md)


GenUI turns DeepSeek Harness (DSH) assistant replies into safe, fully interactive UI surfaces.

[!IMPORTANT] Install GenUI using the full npm package name @changfenhuang/dsh-genui. See Quick Start for setup.

Ask “How are this month’s orders doing?”, and instead of plain text or raw code blocks, the response streams out an interactive sortable data table, audio/video players, draggable function plots, self-grading quizzes, or a persistent workspace dock — all embedded seamlessly within the conversation.


🎬 Real Interface Showcase

[!NOTE] Real Interface Captures: All recordings and screenshots below are captured directly from real DSH interface rendering — no conceptual mockups or faked pre-renders.

40-Second Walkthrough

https://github.com/user-attachments/assets/f5db33ec-7471-4d4a-a85b-79c9962ab4ef

Preview of the complete dsh-genui walkthrough video
(Click the thumbnail to download the original MP4 if the GitHub video player fails to load. The prompt sequence is documented in demo-prompts.md.)

Three Concrete Real Outputs

1. Monitoring Panel: Answer is the Dashboard 2. Function Plot: Drag to Redraw Instantly 3. Composable Hierarchy: Work Surface
Monitoring Panel Function Plot Composable Hierarchy
Data Insights: Eyebrow stats, filterable/drill-down service table, grouped totals, and spark/ring cells directly live in the assistant reply. Zero-Latency Exploration: plot draws mathematical curves; drag parameter sliders to re-calculate and redraw locally in real time. Structured Hierarchy: Display quotes, stat cards, ring progress, and labeled chapter dividers composed declaratively by the model.

✨ Before vs. After

Scenario Plain Text Response With dsh-genui
Business Overview “Revenue this month is ¥128,430 (+12.4% MoM); conversion rate is slightly dipping…” One line of concise prose + 3 stat cards (revenue/orders/conversion), a trend chart, and a progress bar rendered right beside it.
Data Exploration Type another prompt to ask the model to re-sort or filter. Click table headers to sort numbers locally, or use the search box to filter rows in real time.
Parameter Tuning Re-prompt the model and wait for another full generation. Drag sliders to see curves update in sub-millisecond speed with animation preview.
Next Actions Copy text and manually perform follow-up tasks elsewhere. Click interactive action buttons (e.g. “Refresh”, “Switch View”) to trigger bidirectional model event loops.

🚀 Quick Start

1. Prerequisites

Ensure your environment meets the following requirements:

2. Install & Activate

Run a single command in your terminal (all dependencies are fetched automatically):

# Public npm package (works without an npm account)
dsh plugin --profile web add @changfenhuang/dsh-genui

[!TIP] Adding only as a Node package? Run npm install @changfenhuang/dsh-genui. Note that npm install only adds the dependency and does not register the plugin with DSH; use the dsh plugin add command above for DSH integration.

3. Verify in 60 Seconds

  1. Restart the DSH web service and hard refresh your browser (Cmd + Shift + R or Ctrl + F5).
  2. In a new conversation session, send:
    Use dsh-ui to draw a stats dashboard with a sortable service table.
    
  3. Expected result: The reply renders an in-place interactive dashboard rather than a plain code block.
  4. Console activation check: Open your browser Developer Tools Console and look for [genui] client active; fence-channel=dom.

[!WARNING]

⚠️ Installation Pitfalls to Avoid

  1. Do Not Use link: on a Freshly Cloned Directory: link: alone does not bundle or resolve peer assets (mermaid, three.js, React). Use npm for standard usage; reserve link: strictly for local development (see Developer Guide).
  2. Migrating from Legacy @omdsh-dev: If you installed from GitHub or the old org name before v0.9.2, clean up the stale key:
    dsh plugin --profile web remove @omdsh-dev/dsh-genui
    dsh plugin --profile web add @changfenhuang/dsh-genui
    

🧩 Capability Matrix

Every component and behavior is guarded by the strict dsh-ui specification. See SKILL.md for full JSON schema details.

dsh-genui Capabilities
├── 🌊 1. Streaming & Realtime Mounting
├── 🎨 2. 30+ Component Ecosystem
├── ⚡ 3. Local-First Responsiveness
├── 🔄 4. Bidirectional Action Event Loop
├── 📌 5. Persistent Session Workspace & Templates
└── 🛡️ 6. Sandboxing, Guards & Self-Healing

1. 🌊 Streaming & Realtime Mounting

2. 🎨 30+ Component Ecosystem

3. ⚡ Local-First Responsiveness

4. 🔄 Bidirectional Action Event Loop

5. 📌 Persistent Session Workspace & Templates

6. 🛡️ Sandboxing, Guards & Self-Healing


💻 Quick Examples

Example 1: Executive KPI Dashboard

The model emits the following dsh-ui code block:

{
  "title": "Q3 2026 Executive Overview",
  "items": [
    {
      "type": "row",
      "items": [
        { "type": "stat", "label": "Total Revenue", "value": "¥128,430", "delta": "+12.4%", "spark": [40, 55, 60, 85, 120] },
        { "type": "stat", "label": "Completed Orders", "value": "1,024", "delta": "-3.1%", "spark": [90, 85, 80, 75, 70] },
        { "type": "progress", "label": "Quarterly Target", "value": 82, "variant": "ring" }
      ]
    }
  ]
}

Example 2: ECharts Revenue Trend

{
  "title": "Revenue Breakdown",
  "items": [
    {
      "type": "echart",
      "title": "Monthly Performance",
      "preset": "bar",
      "data": [
        { "label": "Jan", "value": 98 },
        { "label": "Feb", "value": 112 },
        { "label": "Mar", "value": 128 },
        { "label": "Apr", "value": 145 },
        { "label": "May", "value": 160 }
      ]
    }
  ]
}

For the comprehensive specification and full component catalog, refer to SKILL.md.


⚙️ Architecture & How It Works

sequenceDiagram
    autonumber
    actor User as User
    participant Host as DSH Host / LLM
    participant DOM as Conversation DOM
    participant GenUI as GenUI Client Renderer
    participant Assets as On-Demand Assets (ECharts/Three)

    User->>Host: Prompt (e.g. "Analyze recent order trends")
    Host-->>DOM: Streams Markdown prose & ```dsh-ui fence
    DOM->>GenUI: Detects fence and normalizes schema against whitelist
    alt Requires Heavy Engines
        GenUI->>Assets: Dynamically fetches engine bundles
        Assets-->>GenUI: Assets loaded
    end
    GenUI->>DOM: Mounts React component tree incrementally
    opt Client-Side Local Actions
        User->>GenUI: Sort table / Drag plot slider / Answer quiz
        GenUI-->>User: Instant sub-millisecond local update
    end
    opt Model Action Feedback
        User->>GenUI: Click interactive action button
        GenUI->>Host: Dispatches structured action payload
        Host-->>DOM: Model responds with next-step reasoning / updates panel
    end

Artifact Exporting

Completed GenUI blocks can be exported on demand:


🧑‍💻 Developer Guide

git clone https://github.com/omdsh-dev/dsh-genui.git
cd dsh-genui
pnpm install

# Build and link into your DSH web profile
dsh plugin --profile web add link:$PWD

Useful Commands

pnpm run check           # Type checks + full unit test suite + build
pnpm run test            # Run Vitest unit tests
pnpm run check:host-api dsh-v0.2.1-rc.3  # Check the retained rc.3 host API
pnpm run check:host-api dsh-v0.2.1-rc.4  # Check the earlier rc.4 API
pnpm run check:host-api dsh-v0.2.1-rc.5  # Check the earlier rc.5 API, full suite and build
pnpm run check:host-api dsh-v0.2.2-rc.1  # Check the current npm latest / next API, full suite and build
pnpm run check:host-api dsh-v0.2.2-alpha.2  # Check the supported npm alpha API, full suite and build
node scripts/verify-pack.mjs --keep  # Verify and inspect npm tarball

End-to-End (E2E) Testing

CI and the release workflow install 0.2.2-alpha.2 from npm with node scripts/prepare-published-host.mjs 0.2.2-alpha.2, then verify the packed plugin in a fresh web profile. This lane uses DSH_HOST_LAYOUT=registry and DSH_HOST_VERSION=0.2.2-alpha.2 with the returned DSH_ROOT and DSH_BIN; the source-host lanes remain pinned to their official tags. The same registry-host lane also installs 0.2.2-rc.1, with DSH_HOST_VERSION=0.2.2-rc.1. Registry-host checks pin Cordis framework dependencies to the versions recorded in each host’s published manifest so later dependency resolution cannot change the host graph. Both current RC and alpha API, gallery/computed and Linux Map checks must pass before npm publication. Actions use official local replay; Android device and original Windows Desktop acceptance remain separate.

Advanced Profile Configurations

To customize plugin behaviors, add configurations under cordis.patch.yml in your profile:

- id: genui
  name: '@changfenhuang/dsh-genui'
  config:
    renderUiTool: false   # Disable registering the render_ui tool card (fences and panel remain active)
    fenceFeedback: false  # Disable automatic same-turn steer correction on malformed fences
    fenceSection: full    # full (default), minimal, or false

fenceSection controls both fence guidance detail and usage preference:

Mode Behavior
full (default) Provides syntax and essential rules, and proactively uses components for comparisons along shared dimensions, numerical trends, process dependencies, and user interaction, without waiting for a reminder.
minimal Keeps only the fence example and the requirement to load the GenUI skill; user instructions determine usage preference.
false Omits the genui:fence section.

Requirement words follow RFC 2119: valid JSON, current fields, and explicit user language and presentation requirements are MUST rules. In full, using appropriate UI for comparisons, trends, dependencies, and interaction is SHOULD guidance; card wrappers are MAY. full sets no list-length trigger or component quota. Ordinary explanations and short lists default to prose. Modes guide behavior rather than guaranteeing a fixed usage rate.

Use fences for inline reply content, render_ui for a standalone UI in the tool result, and panel:true for the session panel that updates in place. Both fences and tools preserve interaction state; choose by placement. card is an optional container: avoiding unnecessary card wrappers does not mean avoiding GenUI.

Skill availability is resolved in the current agent's tool view, including preset-owned loaders; a global skill registration is not required. The visible tool must expose the Skill loader contract, and genui must allow model invocation. When the skill already includes current fields, no component reference is injected. An older skill receives only missing or changed field descriptions in genui:reference; appended user preferences do not trigger a full reference. User skill files remain untouched, and current system fields take precedence over loaded older fields.

If a compatible loader or model-invocable GenUI skill is unavailable, a compact field reference is supplied for fence guidance or an available render_ui tool. fenceSection: false omits fence guidance; disabling both fence guidance and render_ui also omits the reference. Neither setting disables fence rendering or panels. The dsh-go genui:native section and tool definitions have independent guidance and token costs. Loading the full skill for an actual UI response still consumes context; this change removes the unconditional duplicate catalog rather than making that load free.

Embedding into Other Applications

You can import GenuiBlock, GenuiActionContext, and processGenuiSpec from @changfenhuang/dsh-genui/embed to embed the renderer into any React application supporting CSS Modules.

dsh-go integration

The dsh-go integration uses the App’s existing native cards, inline choices and plugin panels; no App patch or replacement APK is needed. The complete web spec stays authoritative. Native panels support choices, switches, buttons, submissions, local grading, tabs, accordions, copy and confirmed HTTPS links. Validation can produce one JSON fence readable by both renderers. Panels currently require the local-engine dsh-go bridge; SSH and relay hosts retain native tool cards. Advanced graphics and free-text input remain explicit limitations. See capabilities and verification.

Theming: non-opaque host canvases

Every surface resolves through one chain: --dsl-g-surface → --dsh-genui-surface → --dsw-alias-bg-layer-2 → … → #fff. A skin that paints the page itself (wallpaper, glass / translucent look) can pin the surface once without touching the host's own tokens:

:root { --dsh-genui-surface: rgba(255, 255, 255, 0.58); }
body[data-ds-dark-theme] { --dsh-genui-surface: rgba(32, 32, 34, 0.54); }

callout and toned card washes are painted over that surface, so they stay readable on any canvas. card.flat and table are surface-less by design (a printed block, a bare data grid) and would show a non-opaque page through — they fill only when a skin asks for it:

:root {
  --dsh-genui-surface: rgba(255, 255, 255, 0.58);      /* cards, callouts, controls */
  --dsh-genui-surface-flat: var(--dsh-genui-surface);  /* card.flat */
  --dsh-genui-surface-table: var(--dsh-genui-surface); /* table */
}

Leaving the last two unset keeps today's look (transparent table, 2.5% printed flat card); pointing them at var(--dsh-genui-surface) gives all three one fill. Wrapping a table in a card fills it too, since the parent surface shows through (issue #398).


Sidechat surfaces (optional)

GenUI can render settled dsh-ui fences on provider-declared sidechat surfaces. BetterSidebar uses its registerSidechatSurfaceAdapter capability; other providers can expose the optional genuiSidechat Cordis service. Each surface carries its owning thread identity and prompt callback, so actions and interaction state stay within that child thread. Streaming rows and unsupported or invalid fences keep their original Markdown.

See the sidechat surface adapter contract. BetterSidebar support requires a release containing its provider implementation; the released 0.28.0 does not expose registerSidechatSurfaceAdapter. The DSH native Side Chat provider must expose genuiSidechat to enable this integration.

❓ FAQ & Troubleshooting

Q: Why are dsh-ui fences still showing up as raw code blocks?
  1. Open your browser Developer Tools (F12) and inspect the Console.
  2. Search for the log [genui] client active; fence-channel=dom:
    • If missing: The client bundle was not activated by the host. Verify that dsh plugin list shows the plugin as active, restart DSH web, and hard refresh your browser;
    • If present: Check whether the code block language identifier is strictly dsh-ui and that its body contains valid JSON.
Q: Error: "pnpm not found on PATH"?

DSH plugin management calls pnpm under the hood. Run corepack enable or npm i -g pnpm, then open a new terminal window before running dsh plugin add.

Q: npm install returns 404?

The package is public and requires no login. Verify the package name via npm view @changfenhuang/dsh-genui version. If a version was published very recently, allow a few moments for registry mirrors to synchronize.

Q: 3D scene, Mermaid, or ECharts does not render?

Heavier engines are lazy-loaded through plugin-provided static routes upon their first appearance. Hard refresh your browser (Cmd + Shift + R). If the issue persists, reinstall the package:

dsh plugin --profile web remove @changfenhuang/dsh-genui
dsh plugin --profile web add @changfenhuang/dsh-genui
Q: The chat screen goes blank when rendering a fence?

This version requires DSH ^0.2.0-rc.1 || ^0.2.1-rc.1 || ^0.2.2-alpha.2. Older host versions lack necessary React slot/context capabilities; please upgrade DSH.


🗺️ Roadmap Evaluation

Exploration Area Decision Rationale
Incremental Diff Patching Declined A fence costs only 200–800 tokens; resending is fast and safe. Teaching models a patch diff protocol introduces high friction and hallucination rates.
Granular Action Delivery ✅ Done Discrete gestures send immediately; continuous slider drags apply trailing-edge debounce to keep chat context clean.
Cross-Session Replay Persistence Declined Resetting on replay is the more natural expectation when the model updates the UI; state is preserved seamlessly during streaming.
Separate Gallery / i18n Strings Declined The component gallery is covered by demo-prompts, gallery.ts, and README screenshots; the core bundle carries only 6 built-in UI strings.


📄 License

This project is licensed under the MIT License.

Interactive maps

The map node combines lazy MapLibre markers and inline routes with an always-available keyboard-operable location list. Selection stays local and can be persisted/submitted as a stable location ID through the existing fields contract. The default is an offline blank coordinate map, not a street basemap; external styles belong to trusted host configuration, never model JSON. See the map contract and embedding/export guide.

dsh-genui (omdsh-dev/dsh-genui)

正在搜索数据库…

这是什么?dsh-genui 是 DeepSeek Harness(DSH)的一个插件,它用特殊的 dsh-ui 代码围栏把模型的文字回复变成可交互的内联 UI——图表、表格、表单、测验、Mermaid 图、3D 场景——并通过事件循环把 UI 交互回传给模型。
这是一个独立应用,还是我添加到现有工具上的插件?它是面向 DSH 的插件包,不是独立应用:它包含一个教会 DSH 识别 dsh-ui 围栏语法的主插件、一个挂载这些组件的浏览器渲染器,以及一个内置的 genui 技能——全部存在于你的 DSH 安装之中。
我怎么把 dsh-genui 添加到我的 DSH 环境?普通的 npm install 只会把包作为依赖添加——你必须运行专门的 dsh plugin add 命令,DSH 才会真正注册该插件,然后重启 dsh web 并强制刷新浏览器进行验证。
运行它需要什么版本的 DSH?dsh-genui 0.9.9 固定配套特定的 DSH 发布线,即 dsh ^0.1.2-rc.1 或 ^0.1.5-alpha.1;在其他 DSH 版本上它无法正确激活。
有哪些安装坑我应该避免?不要在刚克隆的目录里用 link: 模式安装——它会跳过安装渲染器自身的依赖(mermaid/three/react)并破坏渲染;正常安装请使用常规的 npm 命令,把 link: 留给活跃的本地开发。
生成的 UI 会不会索要密码或 API 密钥?不会——GenUI 执行严格的机密信息禁令:它绝不能索要密码、API 密钥、token 或恢复码;即便出现密码输入框,它也会保持掩码显示、永不持久化,并被排除在表单提交之外。
模型在回复中可以使用哪些 UI 组件?dsh-genui 内置 30 多个白名单组件——卡片、表格、图表、表单、标签页、折叠面板、文件树、时间线、diff、测验、Mermaid 图、ECharts、函数图像以及面向 3D 的场景——全部内联渲染在助手的文字之中。
UI 如何把信息回传给模型?交互元素(按钮、输入框、开关、测验)带有 action 字段;点击或失焦时,值会通过事件循环回传给模型,同名 action 以 300 毫秒防抖,因此快速点击会合并为一次更新。
页面刷新后 UI 状态还在吗?在——答案、提交锁和输入值会按会话加内容指纹保存,因此刷新或重新打开都能恢复全部状态,上限为 LRU 的 200 个块。
如果模型输出格式错误的组件规格会怎样?内置的规格守卫会静默丢弃错误节点、钳制数值并截断字符串,把整棵树限制在 200 个节点 / 8 层嵌套以内,因此损坏的规格绝不会让 UI 崩溃;Mermaid 渲染失败时甚至会先用文本修复自动重试,最后才退回到纯源码。
作者
omdsh-dev
大小
23.5 MB
星标
1K
时长
3个月
提交 · 90 天