@yunkersek/dsh-prtsui 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +82 -2
- package/SKILL.md +72 -0
- package/client.js +750 -0
- package/cordis.patch.yml +6 -0
- package/docs/harness.html +785 -0
- package/docs/prtsui-preview.png +0 -0
- package/icon.svg +9 -0
- package/index.js +200 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +59 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-prts authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yunkersek/dsh-prtsui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 安装
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# A. 作为 DSH bundle 安装(推荐,热生效,不必刷新页面)
|
|
7
|
+
plugin_manager install_bundle target "@yunkersek/dsh-prtsui"
|
|
8
|
+
|
|
9
|
+
# B. 与 dsh-genui 二选一:两者都监听 ```dsh-ui 围栏,不能同时启用
|
|
10
|
+
plugin_manager set_plugin target "include:genui" enabled false
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
卸载:`plugin_manager remove_bundle target "@yunkersek/dsh-prtsui"`。
|
|
14
|
+
|
|
15
|
+
PRTS 版 GenUI:把助手回复里的 ` ```dsh-ui ` 围栏渲染成 **prts-design 视觉语言** 的结构化卡片。
|
|
16
|
+
它是 `@changfenhuang/dsh-genui` 的同功能替代品(围栏通道),纯 DOM 实现,不加载 React DOM、不下载任何外部资源。
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
@yunkersek/dsh-prtsui
|
|
20
|
+
├─ package.json @yunkersek/dsh-prtsui,dsh.bundle.patch + dsh.client
|
|
21
|
+
├─ cordis.patch.yml 插入 id=prtsui
|
|
22
|
+
├─ index.js 宿主半:系统提示段、skills provider、render_prtsui / validate_prtsui
|
|
23
|
+
├─ client.js 浏览器半:围栏发现 + PRTS 组件渲染(22 种节点)
|
|
24
|
+
├─ SKILL.md 技能正文(围栏用法、节点表、视觉规则)
|
|
25
|
+
├─ icon.svg locale/ 插件详情用图标与文案
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 预览
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
上图是 `docs/harness.html` 的离线自检:一个 JSON 围栏渲染成标题横幅 + hero + 三格统计 + 警示条 + 表格 + 三步时间线 + 条形图 + 分段进度 + 选项 + 清单。harness 把 `client.js` 内联进页面,模拟 `window.__ModuleLoader__` 与占位 ctx,用来在真实 Chromium 里验证“围栏 → 卡片”的整条链路(`status: applied | mounted: 1`)。
|
|
33
|
+
|
|
34
|
+
## 与 dsh-genui 的差异
|
|
35
|
+
|
|
36
|
+
| 能力 | dsh-genui | @yunkersek/dsh-prtsui |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| ```dsh-ui 围栏渲染 | ✅ React 树 + 内置图标库 | ✅ 纯 DOM + PRTS 样式 |
|
|
39
|
+
| 组件词表 | ~40 种 | 22 种(text/hero/callout/list/table/stat/stats/keyvalue/steps/choices/tabs/card/chart/code/divider/kbd/badge/progress/quote/compare/image/accordion) |
|
|
40
|
+
| 图表 | echarts | 手写 SVG(bars/line/donut) |
|
|
41
|
+
| 工具行渲染 `render_ui` | ✅ toolview | ⚠️ `render_prtsui` 只回文本摘要(未注册 toolview) |
|
|
42
|
+
| 会话面板 dock(`panel:true`) | ✅ | ❌ 暂按内联处理 |
|
|
43
|
+
| 流式逐组件装配 | ✅ | ❌ 等围栏 JSON 完整后一次挂载 |
|
|
44
|
+
| 外部资产(echarts/mermaid/three/maplibre/katex) | ~8MB | 0 |
|
|
45
|
+
| 主题 | 跟随宿主 token | 直接吃宿主 `--dsw-alias-*`,因此 PRTS 主题与自绘皮肤同时成立 |
|
|
46
|
+
|
|
47
|
+
已安装但禁用:`@changfenhuang/dsh-genui`(v0.17.0)保留在 profile 里,需要时可 `plugin_manager set_plugin enabled=true` 切回。
|
|
48
|
+
|
|
49
|
+
## 用法
|
|
50
|
+
|
|
51
|
+
1. 助手输出围栏(一个 JSON 对象):
|
|
52
|
+
|
|
53
|
+
````
|
|
54
|
+
```dsh-ui
|
|
55
|
+
{"title":"迁移进度","items":[{"type":"progress","value":0.62,"label":"步骤 4/7"},{"type":"callout","tone":"warning","content":"仍有两个模块未接入。"}]}
|
|
56
|
+
```
|
|
57
|
+
````
|
|
58
|
+
|
|
59
|
+
2. 客户端 MutationObserver 抓到代码块 → `JSON.parse` → 命中已知 `type` 即挂载,原 `<pre>` 隐藏。
|
|
60
|
+
3. 交互节点(tabs / accordion / choices)本地生效;带 `action` 的节点点击后回传 `[prtsui-action] <action> {…}`。
|
|
61
|
+
|
|
62
|
+
## 识别规则(为什么不用语言标记)
|
|
63
|
+
|
|
64
|
+
DSH 的代码块 DOM 不带 `language-*` 类,围栏语言在渲染层已丢失。因此识别靠内容:
|
|
65
|
+
文本以 `{` 或 `[` 开头、能 `JSON.parse`、且 `items` 中至少一个节点 `type` 命中白名单;未知类型占比 > 50% 时判定为普通 JSON 并跳过,避免把普通 JSON 误渲染成卡片。
|
|
66
|
+
|
|
67
|
+
## 样式来源
|
|
68
|
+
|
|
69
|
+
prts-design 的终端(暗)/站点(亮)两套语义令牌 + 组件规格:
|
|
70
|
+
- 卡片:1px 发丝边框、`border-radius: 2px`、左上 38×2 青色刻度
|
|
71
|
+
- 小标签:10px / 大写 / `letter-spacing: .12–.16em` / `label-secondary`
|
|
72
|
+
- 列表与菜单项:左侧 2px 青轨(可透明),hover/选中转青
|
|
73
|
+
- 表格:表头大写 mono、单元格发丝下边线、数字 `tabular-nums` 右对齐
|
|
74
|
+
- 统计:1px 网格切分,数值 18px/700 mono
|
|
75
|
+
- 图表:手写 SVG,1.5px 青色折线、方形端点、发丝基线
|
|
76
|
+
- 状态色:success `#4fd18f`、warning `#ffb340`、error `#ff5c5c`、info `#5ddcff`(亮色主题由宿主 token 自动换)
|
|
77
|
+
|
|
78
|
+
## 已知边界
|
|
79
|
+
|
|
80
|
+
- 围栏必须等 JSON 完整才渲染(流式中途显示为普通代码块)。
|
|
81
|
+
- `panel:true` 未实现 dock;`render_prtsui` 没有 toolview,工具行只出文本。
|
|
82
|
+
- 组件词表比 genui 少,复杂交互(表单、滑块、多级筛选)请回退 genui。
|
|
83
|
+
- 与 genui 同用会争抢同一批围栏:两个插件不应同时启用。
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prtsui
|
|
3
|
+
description: Render structured interactive UI inline with the PRTS (明日方舟 / 终端) visual language using a ```dsh-ui fence. Use instead of dsh-genui when a comparison, status, steps, table, stats, chart, choices, or card layout is clearer than prose.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# prtsui — PRTS 风的结构化内联 UI
|
|
7
|
+
|
|
8
|
+
本插件接管 ```dsh-ui 围栏:围栏里的 JSON 会被渲染成 PRTS 风格的卡片,**不是** 代码块。
|
|
9
|
+
它替代 `dsh-genui`(已安装但禁用,随时可切回)。
|
|
10
|
+
|
|
11
|
+
## 什么时候用
|
|
12
|
+
|
|
13
|
+
- 需要比较 2–4 个选项 / 前后对照 → `table`、`compare`、`choices`
|
|
14
|
+
- 汇报状态、进度、指标 → `stats`、`progress`、`list`、`callout`
|
|
15
|
+
- 说明流程、分支、实施顺序 → `steps`、`accordion`
|
|
16
|
+
- 需要用户点选、筛选、决定 → `choices`(带 `action`)
|
|
17
|
+
- 单个结论要突出 → `hero` + `callout`
|
|
18
|
+
|
|
19
|
+
普通解释、短清单默认用正文;只有结构化更清楚时才出围栏,且信息只呈现一次。
|
|
20
|
+
|
|
21
|
+
## 围栏格式
|
|
22
|
+
|
|
23
|
+
````
|
|
24
|
+
```dsh-ui
|
|
25
|
+
{"title":"可选的横幅标题","gap":10,"items":[{"type":"table","columns":["维度","A"],"rows":[["延迟","12ms"]]}]}
|
|
26
|
+
```
|
|
27
|
+
````
|
|
28
|
+
|
|
29
|
+
- 一个围栏一个 JSON 对象:`{"items":[…], "title"?, "gap"?}`;也接受裸数组。
|
|
30
|
+
- 不要嵌套围栏、不要在里面写 Markdown、不要加注释。
|
|
31
|
+
- 放在引入它的那句话之后,而不是长回答的末尾。
|
|
32
|
+
|
|
33
|
+
## 节点
|
|
34
|
+
|
|
35
|
+
| type | 关键字段 |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `text` | `content` |
|
|
38
|
+
| `hero` | `eyebrow` `title` `subtitle` `content` |
|
|
39
|
+
| `callout` | `tone`: info/success/warning/error/brand,`title` `content` |
|
|
40
|
+
| `list` | `items`(字符串或 `{text,badge,tone}`),`ordered` |
|
|
41
|
+
| `table` | `columns[]` `rows[][]` `caption` `align[]` |
|
|
42
|
+
| `stat` / `stats` | `label` `value` `hint` `delta`;`stats.items[]` |
|
|
43
|
+
| `keyvalue` | `pairs:[{key,value}]` |
|
|
44
|
+
| `steps` | `steps:[{title,content,state:done\|active\|todo}]` 或 `current` 索引 |
|
|
45
|
+
| `choices` | `options:[{label,description,value}]` `action` `multiple` |
|
|
46
|
+
| `tabs` | `tabs:[{label,items:[…]}]` |
|
|
47
|
+
| `card` | `eyebrow` `title` `items:[…]`(容器) |
|
|
48
|
+
| `chart` | `kind`: bars/line/donut,`data:[{label,value}]` `unit` `height` |
|
|
49
|
+
| `code` | `content` `language` |
|
|
50
|
+
| `progress` | `value`(0–1 或 0–100) `label` `segments:[{tone,value}]` |
|
|
51
|
+
| `kbd` | `keys:["ctrl","r"]` |
|
|
52
|
+
| `badge` | `content` `tone` |
|
|
53
|
+
| `quote` | `content` `cite` |
|
|
54
|
+
| `compare` | `before:{title,items[]}` `after:{title,items[]}` |
|
|
55
|
+
| `image` | `src` `alt` `caption` |
|
|
56
|
+
| `accordion` | `items:[{title,items:[…]}]` |
|
|
57
|
+
|
|
58
|
+
## 交互
|
|
59
|
+
|
|
60
|
+
- `tabs` / `accordion` / `choices` 的选中状态由客户端本地维护。
|
|
61
|
+
- 节点带 `action`(例如 `{"type":"choices","action":"pick-mode","options":[…]}`)时,点击会回传
|
|
62
|
+
`[prtsui-action] pick-mode {"value":"…"}`,你据此继续。
|
|
63
|
+
- `panel:true` 与工具行渲染尚未实现:保持内联;需要工具行卡片时改用 `render_prtsui` 并说明局限。
|
|
64
|
+
|
|
65
|
+
## 视觉语言(PRTS / prts-design)
|
|
66
|
+
|
|
67
|
+
终端质感:方形直角、1px 发丝描边、青色(`#18d1ff` 系)强调轨与顶部 38px 刻度、大写字母 + 0.12–0.16em 字距的小标签、tabular-nums 的数字、状态色绿/黄/红、列表左侧 2px 青轨。所有可见文案跟随对话语言,不要为了“好看”混入英文。
|
|
68
|
+
|
|
69
|
+
## 校验
|
|
70
|
+
|
|
71
|
+
非平凡围栏先调 `validate_prtsui`(参数 `{"spec":{…}}`),它返回 `status`、节点统计与问题列表;
|
|
72
|
+
`render_prtsui` 是同规格的兜底通道(工具行渲染,宿主无围栏能力时用)。
|