@changfenhuang/dsh-genui 0.11.0 → 0.11.1-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/SKILL.md +1 -0
- package/lib/client.js +20 -20
- package/lib/index.js +661 -49
- package/lib/types/client/fence-render.d.ts +42 -1
- package/lib/types/client/spec.d.ts +32 -14
- package/lib/types/plugin/fence-feedback.d.ts +112 -0
- package/lib/types/plugin/index.d.ts +15 -2
- package/lib/types/plugin/tool.d.ts +5 -0
- package/package.json +19 -18
- package/src/client/GenuiBlock.module.css +4 -0
- package/src/client/dom-fence.tsx +132 -9
- package/src/client/fence-render.tsx +40 -13
- package/src/client/genui-runtime/diagnostics.ts +4 -2
- package/src/client/genui-runtime/normalize.ts +90 -3
- package/src/client/genui-runtime/schema.ts +19 -11
- package/src/client/guard.ts +80 -11
- package/src/client/spec.ts +58 -16
- package/src/plugin/fence-feedback.ts +307 -0
- package/src/plugin/index.ts +26 -8
- package/src/plugin/tool.ts +117 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.11.1-preview.2] - 2026-09-16
|
|
4
|
+
|
|
5
|
+
### 新增
|
|
6
|
+
- DOM 通道对被拒绝的围栏给出**可见诊断**:settled 之后仍无法渲染的 dsh-ui 围栏,会在原始代码块上方显示红色诊断条(字段错误或 JSON 解析原因),原始内容保留;此前只有 `console.warn`,围栏的作者看不到失败原因(#158)。
|
|
7
|
+
- 可选的自修闭环 `fenceFeedback`(默认关闭,profile 配置 `fenceFeedback: true` 开启):回复中的 dsh-ui 围栏未能渲染时,通过宿主的 `agent/turn-stopping` 边界把一条插件来源的修正请求 steer 进**同一回合**,让模型重发修正版。边界:每回合最多一次、同一围栏内容最多一次、子代理会话不触发、精确匹配 `dsh-ui` 围栏、发送前记账、取消的回合不触发(#160)。
|
|
8
|
+
|
|
9
|
+
### 修复
|
|
10
|
+
- 根形状判定不再被重载的 `items` 骗过:根对象带白名单 `type` 时优先按**单组件根**处理(`{"type":"steps","items":[…]}` 此前被当成信封,步骤记录逐个被丢弃后整份围栏被拒);包装结果改为纯 spec 以免守卫二次包裹,根上的 `title` 在组件无该字段时上提为区块标题(#172)。
|
|
11
|
+
- `stat` 指标组 `{"type":"stat","items":[{label,value},…]}` 归一化为一行多个 `stat`(规范的多指标写法),不再丢弃该节点并连坐同围栏里合法的兄弟节点(#172)。
|
|
12
|
+
- `radio` / `select` / `quiz` 的 `items` 别名到 `options`,与 #175 的别名表取并集(#172)。
|
|
13
|
+
- 字段名错误不再让整条围栏降级为代码块:`callout.content`(模型常写 text/body)、`keyvalue.pairs`(常写 items/rows/entries)、`diff.diffs`(常写 items)、`image`/`audio`/`video.src`(常写 url)、`code`/`copy`、`quiz.question`/`options`(常写 title/choices)补进别名表,规范化后照常渲染并保留 warning(#163、#172)。
|
|
14
|
+
- `table` 只在给出行数据(`rows`/`data` 二维数组)而未给 `columns` 时,用首行作为表头推导列名,不再丢弃该节点;行列不齐时按 `列1…列N` 渲染,非二维体仍是契约错误(#172)。
|
|
15
|
+
- `list` 的单元格式写法(`[["文本"]]` 会渲染成空列表)与 `{title, description}`(正文丢失),以及 `keyvalue.pairs` 的 `[[key, value]]` 写法,统一在规范化层转成规范形状(#172)。
|
|
16
|
+
- 常驻提示词新增「字段名写错 = 整个围栏降级为代码块」的负例清单(callout 用 content、table 要 columns+rows、keyvalue 要 pairs),并压缩既有条目保持 #29 的 3200 字符预算。
|
|
17
|
+
- `validate_dsh_ui` 的丢弃诊断从「声明 N / 解析 M」升级为逐节点归因:每个被丢弃节点给出位置、类型、**已写字段**与**缺少的必填字段**(`- items[0](callout)缺少必填字段 content;已写字段 title`),原始错误列表保留(#163)。
|
|
18
|
+
|
|
19
|
+
## [0.11.1-preview.1] - 2026-09-15
|
|
20
|
+
|
|
21
|
+
- 更新 preview 预发布验收宿主至 DSH 0.1.6-alpha.1;发布任务验证同一安装包后发布至 npm preview。
|
|
22
|
+
|
|
3
23
|
## [0.11.0] - 2026-09-15
|
|
4
24
|
|
|
5
25
|
### 新增
|
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ The repository ships both renderer channels, the host plugin, and the built brow
|
|
|
93
93
|
|
|
94
94
|
Prerequisites — all required:
|
|
95
95
|
|
|
96
|
-
1. **dsh `^0.1.2-rc.1 || ^0.1.5-alpha.1`** (dsh-genui 0.11.
|
|
96
|
+
1. **dsh `^0.1.2-rc.1 || ^0.1.5-alpha.1 || ^0.1.6-alpha.1`** (dsh-genui 0.11.1-preview.2 is verified on DSH 0.1.6-alpha.1 and the 0.1.2-rc.1 minimum; users on DSH `<=0.1.1-rc.x` should use dsh-genui `0.9.8`)
|
|
97
97
|
2. **`pnpm` on your PATH**: the `dsh plugin` command depends on it. If missing: `corepack enable` (or `npm i -g pnpm`), then **open a new terminal** and confirm `pnpm -v` prints a version
|
|
98
98
|
|
|
99
99
|
Install and activate in DSH (one command, all dependencies included):
|
|
@@ -215,7 +215,7 @@ The core render package stays light (≈110 KB min / 28 KB gzip); the mermaid, t
|
|
|
215
215
|
## ❓ FAQ
|
|
216
216
|
|
|
217
217
|
- **Rendering as a code block?** First check the browser console for `[genui] client active; fence-channel=registry|dom`. If absent, the client bundle was not activated even if its URL returns 200 — align the profile dependency, `package.json.name`, `cordis.patch.yml`, ModuleLoader id, and configured bundle name. If present, inspect the fence label/body; registry-less hosts automatically use the DOM channel.
|
|
218
|
-
- **Chat UI goes blank when rendering a dsh-ui fence?** This dsh-genui release requires DSH `^0.1.2-rc.1 || ^0.1.5-alpha.1`; users on DSH `<=0.1.1-rc.x` should use dsh-genui `0.9.8`.
|
|
218
|
+
- **Chat UI goes blank when rendering a dsh-ui fence?** This dsh-genui release requires DSH `^0.1.2-rc.1 || ^0.1.5-alpha.1 || ^0.1.6-alpha.1`; users on DSH `<=0.1.1-rc.x` should use dsh-genui `0.9.8`.
|
|
219
219
|
- **`dsh: pnpm not found on PATH`?** Install pnpm, then **open a new terminal** and retry (`corepack enable` or `npm i -g pnpm`).
|
|
220
220
|
- **npm install returns 404?** The npm package is public and requires no login. Run `npm view @changfenhuang/dsh-genui version` to verify the package name and public registry; if a newly published version still returns 404, retry shortly.
|
|
221
221
|
- **Installed but scene3d/mermaid/echarts don't render?** The engines (mermaid / three / echarts) are no longer inlined in client.js — they load on demand the first time they're used (`/plugins/@changfenhuang/dsh-genui/assets/*.js`, hosted by the plugin's own HTTP routes). First restart dsh web + hard refresh (Cmd+Shift+R); still broken, remove and reinstall (`dsh plugin --profile web remove @changfenhuang/dsh-genui`, then add again). Hosts without the asset routes degrade to source/load-error hints — update dsh.
|
package/README.zh-CN.md
CHANGED
|
@@ -93,7 +93,7 @@ https://github.com/user-attachments/assets/f5db33ec-7471-4d4a-a85b-79c9962ab4ef
|
|
|
93
93
|
|
|
94
94
|
前置条件,缺一不可:
|
|
95
95
|
|
|
96
|
-
1. **dsh `^0.1.2-rc.1 || ^0.1.5-alpha.1`**(dsh-genui 0.11.
|
|
96
|
+
1. **dsh `^0.1.2-rc.1 || ^0.1.5-alpha.1 || ^0.1.6-alpha.1`**(dsh-genui 0.11.1-preview.2 已验证 DSH 0.1.6-alpha.1,并保留 0.1.2-rc.1 下限验证;使用 DSH `<=0.1.1-rc.x` 的用户请使用 dsh-genui `0.9.8`)
|
|
97
97
|
2. **`pnpm` 在 PATH 上**:`dsh plugin` 命令依赖它。没有就 `corepack enable`(或 `npm i -g pnpm`),然后**新开一个终端**,确认 `pnpm -v` 有输出
|
|
98
98
|
|
|
99
99
|
安装并在 DSH 中激活(一行命令,自动带上全部依赖):
|
|
@@ -221,7 +221,7 @@ dsh plugin --profile web add link:$PWD
|
|
|
221
221
|
## ❓ 常见问题
|
|
222
222
|
|
|
223
223
|
- **显示成代码块?** 先在浏览器控制台找 `[genui] client active; fence-channel=registry|dom`。没有这行,即使 `client.js` 返回 200,也只是下载了文件、没有激活:请对齐网页配置依赖名、`package.json.name`、`cordis.patch.yml`、ModuleLoader id 和配置中的 bundle 名。出现这行后再查围栏标签/正文;宿主没有 registry 时会自动走 DOM 通道。
|
|
224
|
-
- **渲染 dsh-ui fence 时聊天界面白屏?** 此版 dsh-genui 要求 DSH `^0.1.2-rc.1 || ^0.1.5-alpha.1`;使用 DSH `<=0.1.1-rc.x` 的用户请使用 dsh-genui `0.9.8`。
|
|
224
|
+
- **渲染 dsh-ui fence 时聊天界面白屏?** 此版 dsh-genui 要求 DSH `^0.1.2-rc.1 || ^0.1.5-alpha.1 || ^0.1.6-alpha.1`;使用 DSH `<=0.1.1-rc.x` 的用户请使用 dsh-genui `0.9.8`。
|
|
225
225
|
- **`dsh: pnpm not found on PATH`?** 装 pnpm 后**新开终端**再试(`corepack enable` 或 `npm i -g pnpm`)。
|
|
226
226
|
- **npm 安装返回 404?** npm 包是公开的,无需登录。先执行 `npm view @changfenhuang/dsh-genui version` 核对包名与公共 registry;若新版本刚发布仍返回 404,稍后重试。
|
|
227
227
|
- **装了但 scene3d/mermaid/echarts 不渲染?** 引擎(mermaid / three / echarts)不再内联进 client.js——它们在首次用到时按需加载(`/plugins/@changfenhuang/dsh-genui/assets/*.js`,插件自带 HTTP 路由托管)。先重启 dsh web + 硬刷新(Cmd+Shift+R);仍不渲染就卸掉重装(`dsh plugin --profile web remove @changfenhuang/dsh-genui` 后再 add)。旧版宿主缺少资产路由时会降级显示源码/加载失败提示,更新 dsh 即可。
|
package/SKILL.md
CHANGED
|
@@ -233,6 +233,7 @@ description: "Render structured interactive UI inline in your reply via the dsh-
|
|
|
233
233
|
1. **围栏放哪,组件就出现在哪** —— 文字在前后自然流动,不要用工具、不要解释"这是一个围栏"。**围栏一闭合就立即渲染**(不等整条回答结束),所以可以边写文字边出组件
|
|
234
234
|
2. **组合优先**:复杂界面用 `grid`+`card`+`stat`+`table` 拼,不要追求单一巨型组件
|
|
235
235
|
3. **JSON 必须严格合法,发出前完成 4 步自检**:插件**只**修标点级小错(字符串内半角引号、尾随逗号);**缺括号/错括号等结构错误一律不修**,直接红横幅退化成代码块——写错就重发,别指望兜底。**最容易犯的错:字符串值里用了半角引号 `"`**——中文引语一律写 `“”` 或 `「」`。发出围栏前自检 4 条:① 括号配对:`{` 与 `}`、`[` 与 `]` 数量相等,**收尾序列逐个核对**(长表格最易在最后几行错位:把 `]]}]}` 写成 `]}]}]}`)② 无尾随逗号 ③ 值内引号用中文引号 ④ 最后一个字符必须是 `}`。不要在 JSON 字符串里放 markdown;超长表格/列表拆成多个组件分开发,宁短勿长
|
|
236
|
+
3.5. **字段名逐个核对(写错一个 = 整条围栏降级为代码块)**:某个组件的必填字段写错 / 缺失 → 该组件被丢弃 → 整份 spec 判定不可渲染 → 用户只看到一段裸 JSON。高频误写:`callout` 正文是 `content`(不是 text/body);`table` 要 `columns` + `rows`(不是 data,只给二维 rows 时首行会当表头);`keyvalue` 要 `pairs:[{key,value}]`(不是 items);`diff` 是 `diffs`;图片/音视频是 `src`;`code` 是 `code`、`copy` 是 `text`。拿不准就调 `validate_dsh_ui`,不要凭直觉命名
|
|
236
237
|
4. **不要嵌套围栏**:dsh-ui 里不要再包 ``` 代码围栏
|
|
237
238
|
5. **深色主题友好**:配色选深底亮色;UI 主题跟随应用
|
|
238
239
|
6. **场景判断**:先查上面的映射表 —— 内容类型命中就上对应组件;只有纯文字问答、一句话能说清时才不用
|