@civilization/deepseek-genui 0.0.0-stage → 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ # Bundle patch: one row whose package name is the plugin id.
2
+ # `@civilization/deepseek-genui` declares `dsh.client` in its manifest, so this
3
+ # row also carries the browser half (the sidebar entry and its main panel).
4
+ - insert:
5
+ - id: deepseek-genui
6
+ name: '@civilization/deepseek-genui'
7
+ config: {}
package/icon.svg ADDED
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none">
2
+ <rect x="1" y="1" width="30" height="30" rx="8" fill="#2F6FED"/>
3
+ <path d="M9 11h14M9 16h9M9 21h5" stroke="#FFFFFF" stroke-width="2.2" stroke-linecap="round"/>
4
+ <path d="M22.4 16.8l1.3 3.3 3.3 1.3-3.3 1.3-1.3 3.3-1.3-3.3-3.3-1.3 3.3-1.3z" fill="#FFFFFF"/>
5
+ </svg>
package/index.js ADDED
@@ -0,0 +1,64 @@
1
+ import { createReadStream } from 'node:fs';
2
+ import { stat, readFile } from 'node:fs/promises';
3
+ import { join, normalize, relative, sep } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ export const name = 'deepseek-genui';
7
+ export const inject = {
8
+ webServer: { optional: true },
9
+ skills: { optional: true },
10
+ };
11
+
12
+ const vendorRoot = fileURLToPath(new URL('./vendor/', import.meta.url));
13
+
14
+ export async function apply(ctx) {
15
+ // 1. 注册 DSH Agent Skill 认知协议
16
+ try {
17
+ const skillPath = new URL('./skills/agent-genui/SKILL.md', import.meta.url);
18
+ const skillText = await readFile(skillPath, 'utf8');
19
+ const content = skillText.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '').trim();
20
+ ctx.effect(() => ctx.skills?.register({
21
+ name: 'agent-genui',
22
+ description: '生成基于 ```agent-genui 协议的高保真、交互式卡片、图表与架构可视化界面组件(GenUI),聊天对话流将自动将其就地渲染为活体卡片。',
23
+ whenToUse: '当用户要求生成 GenUI 卡片、交互组件、数据大屏、指标看板、流程图、架构拓扑、时序图、生命周期状态机、交互表单、方案对比或需要以可视化界面呈现分析结果时使用。',
24
+ source: 'bundled',
25
+ content,
26
+ }));
27
+ } catch {
28
+ // 容错处理:即使读取 skill 异常也不影响其余服务
29
+ }
30
+
31
+ // 2. 托管本地 Mermaid 等离线静态 Vendor 资源
32
+ if (ctx.webServer) {
33
+ ctx.effect(() => ctx.webServer.register({
34
+ kind: 'prefix',
35
+ path: '/deepseek-genui/vendor',
36
+ handler: async (req, res) => {
37
+ try {
38
+ const url = new URL(req.url || '/', 'http://localhost');
39
+ const prefix = '/deepseek-genui/vendor';
40
+ const requested = decodeURIComponent(url.pathname.slice(prefix.length)).replace(/^[/\\]+/, '') || 'mermaid.min.js';
41
+ const candidate = normalize(join(vendorRoot, requested));
42
+ const rel = relative(vendorRoot, candidate);
43
+ if (rel.startsWith('..') || rel.includes(`..${sep}`)) {
44
+ res.statusCode = 403;
45
+ return res.end('Forbidden');
46
+ }
47
+ const info = await stat(candidate);
48
+ if (!info.isFile()) {
49
+ res.statusCode = 404;
50
+ return res.end('Not found');
51
+ }
52
+ res.statusCode = 200;
53
+ res.setHeader('Content-Type', 'application/javascript; charset=utf-8');
54
+ res.setHeader('Content-Length', info.size);
55
+ res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
56
+ createReadStream(candidate).pipe(res);
57
+ } catch {
58
+ res.statusCode = 404;
59
+ res.end('Not found');
60
+ }
61
+ },
62
+ }));
63
+ }
64
+ }
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "DeepSeek GenUI",
4
+ "description": "Adds a GenUI entry to the sidebar panel list and the main panel it opens."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "DeepSeek GenUI",
4
+ "description": "在侧边栏面板列表中新增 GenUI 入口,以及该入口打开的主面板。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@civilization/deepseek-genui",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Enterprise-ready GenUI panel bundle for DeepSeek Harness with 7-dimensional component system, offline Mermaid/ReactFlow, and host fault isolation.",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "author": "civilization-os",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/civilization-os/deepseek-harness-genui.git"
12
+ },
13
+ "homepage": "https://github.com/civilization-os/deepseek-harness-genui#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/civilization-os/deepseek-harness-genui/issues"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "keywords": [
21
+ "deepseek",
22
+ "dsh",
23
+ "genui",
24
+ "generative-ui",
25
+ "mermaid",
26
+ "reactflow",
27
+ "agent-ui",
28
+ "data-visualization"
29
+ ],
30
+ "scripts": {
31
+ "verify": "node --check client.js && node --check index.js",
32
+ "test": "node --check client.js && node --check index.js",
33
+ "pack": "npm pack"
34
+ },
35
+ "exports": {
36
+ ".": "./index.js",
37
+ "./client": "./client.js",
38
+ "./locale/*.json": "./locale/*.json",
39
+ "./icon": "./icon.svg",
40
+ "./package.json": "./package.json"
41
+ },
42
+ "files": [
43
+ "index.js",
44
+ "client.js",
45
+ "cordis.patch.yml",
46
+ "locale/*.json",
47
+ "icon.svg",
48
+ "vendor/**",
49
+ "skills/**",
50
+ "agent-genui-system-design.md",
51
+ "README.md"
52
+ ],
53
+ "dsh": {
54
+ "bundle": {
55
+ "patch": "./cordis.patch.yml"
56
+ },
57
+ "client": {
58
+ "platform": "web",
59
+ "immediately": true,
60
+ "inject": [
61
+ "@deepseek-ai/dsh-client-locale",
62
+ "@deepseek-ai/dsh-client-ui-layout",
63
+ "@deepseek-ai/dsh-client-ui-sidebar"
64
+ ]
65
+ }
66
+ }
67
+ }
@@ -0,0 +1,312 @@
1
+ ---
2
+ name: agent-genui
3
+ description: 生成基于 ```agent-genui 协议的高保真、交互式卡片、图表与架构可视化界面组件(GenUI),聊天对话流将自动将其就地渲染为活体卡片。
4
+ whenToUse: 当用户要求生成 GenUI 卡片、交互组件、数据大屏、指标看板、流程图、架构拓扑、时序图、生命周期状态机、交互表单、方案对比或需要以可视化界面呈现分析结果时使用。
5
+ source: bundled
6
+ ---
7
+
8
+ # Agent GenUI 交互卡片生成规范指南
9
+
10
+ `@civilization/deepseek-genui` 为 DeepSeek Harness (DSH) 提供了原生的 Generative UI 运行时与聊天流内就地渲染能力。
11
+
12
+ 当你输出被 ````agent-genui` 代码块包裹的标准 JSON DSL 时,DSH 聊天流会自动拦截该代码块并原地渲染为高保真、可交互的活体卡片(支持图表 Tooltip 悬停、React Flow 拓扑拖拽与缩放、表单填写、方案采纳提交等)。
13
+
14
+ ---
15
+
16
+ ## 📌 输出规范(格式与约束)
17
+
18
+ 在回复用户时,请先输出简明扼要的结论或文字说明,然后**直接输出包裹在 ````agent-genui` 代码块中的完整 JSON 描述**:
19
+
20
+ ```agent-genui
21
+ {
22
+ "protocol": "agent-genui",
23
+ "version": "1.0",
24
+ "id": "ui_cluster_report",
25
+ "title": "生产集群全景分析与健康度看板",
26
+ "layout": { "type": "stack", "gap": "md" },
27
+ "children": [
28
+ ...
29
+ ]
30
+ }
31
+ ```
32
+
33
+ ### 顶级根结构字段
34
+ - `protocol`: 固定为 `"agent-genui"`(必须字段)
35
+ - `version`: 固定为 `"1.0"`(必须字段)
36
+ - `id`: 全局唯一标识,例如 `"ui_order_stats"`(必须字段)
37
+ - `title`: 卡片顶部显示的标题名称(可选)
38
+ - `layout`: 布局容器,`{ "type": "stack" | "grid" | "row", "gap": "sm" | "md" | "lg" }`(必须字段)
39
+ - `children`: 组件节点数组(必须字段)
40
+
41
+ 每个子组件节点必须包含:
42
+ - `id`: 节点内唯一标识(例如 `"metric_1"`、`"chart_cpu"`)
43
+ - `type`: 组件类型名称(见下方组件速查表)
44
+ - `props`: 传递给该组件的属性配置对象
45
+
46
+ ---
47
+
48
+ ## 🎨 核心组件清单与典型模板
49
+
50
+ ### 1. 指标看板(`type: "metric"`)
51
+ 用于关键 KPI、统计指标、趋势变化展示:
52
+ ```json
53
+ {
54
+ "id": "m1",
55
+ "type": "metric",
56
+ "props": {
57
+ "title": "当前 QPS 吞吐",
58
+ "value": "12,480",
59
+ "unit": "req/s",
60
+ "change": "+18.2%",
61
+ "changeType": "up"
62
+ }
63
+ }
64
+ ```
65
+ *`changeType` 可选:`"up"`(绿色增长)、`"down"`(橙/红下降)、`"neutral"`(持平)。*
66
+
67
+ ---
68
+
69
+ ### 2. 统计图表(`type: "chart"`)
70
+ 支持完整的笛卡尔坐标系、数值网格、刻度标签、单位显示与鼠标悬停数值 Tooltip:
71
+ ```json
72
+ {
73
+ "id": "c1",
74
+ "type": "chart",
75
+ "props": {
76
+ "chartType": "line",
77
+ "title": "24小时吞吐趋势走势图",
78
+ "yAxisUnit": "req/s",
79
+ "series": [
80
+ { "label": "00:00", "value": 3200 },
81
+ { "label": "04:00", "value": 1800 },
82
+ { "label": "08:00", "value": 7500 },
83
+ { "label": "12:00", "value": 12480 },
84
+ { "label": "16:00", "value": 11200 },
85
+ { "label": "20:00", "value": 9800 }
86
+ ],
87
+ "target": 15000
88
+ }
89
+ }
90
+ ```
91
+ *`chartType` 支持:`"line"` (折线图)、`"bar"` (柱状图)、`"area"` (面积图)、`"scatter"` (散点图)、`"radar"` (雷达图)、`"pie"` (饼图)、`"donut"` (环形图)。*
92
+
93
+ ---
94
+
95
+ ### 3. 分布式系统架构拓扑(`type: "diagram"`, `diagramType: "architecture"`)
96
+ **同时支持 React Flow 画布与 Mermaid 分层视图**,支持端口光晕、节点悬停微动与动态光流虚线:
97
+ ```json
98
+ {
99
+ "id": "arch1",
100
+ "type": "diagram",
101
+ "props": {
102
+ "diagramType": "architecture",
103
+ "title": "现代端到端服务分层拓扑架构",
104
+ "tiers": [
105
+ { "name": "接入层 (Client & CDN)", nodes: ["Web 宿主", "移动端 App", "桌面端 DSH"] },
106
+ { "name": "网关安全层 (API Gateway)", nodes: ["WAF 防护", "Kong 网关", "OAuth2 鉴权中心"] },
107
+ { "name": "核心服务层 (Core Services)", nodes: ["Agent Runtime", "GenUI 渲染服务", "任务编排器"] },
108
+ { "name": "存储与缓存 (Storage & DB)", nodes: ["Redis 缓存", "PostgreSQL", "向量数据库"] }
109
+ ]
110
+ }
111
+ }
112
+ ```
113
+
114
+ ---
115
+
116
+ ### 4. 业务链路流程图(`type: "diagram"`, `diagramType: "flowchart"`)
117
+ 基于 Mermaid 10.x 离线引擎编译,节点 ID 严禁使用 `end`、`subgraph` 等保留字(推荐使用 `success`、`node_1` 等):
118
+ ```json
119
+ {
120
+ "id": "flow1",
121
+ "type": "diagram",
122
+ "props": {
123
+ "diagramType": "flowchart",
124
+ "direction": "LR",
125
+ "nodes": [
126
+ { "id": "start", "label": "用户发起请求" },
127
+ { "id": "auth", "label": "鉴权与限流" },
128
+ { "id": "exec", "label": "扣减库存" },
129
+ { "id": "success", "label": "回包成功" }
130
+ ],
131
+ "edges": [
132
+ { "from": "start", "to": "auth" },
133
+ { "from": "auth", "to": "exec" },
134
+ { "from": "exec", "to": "success" }
135
+ ]
136
+ }
137
+ }
138
+ ```
139
+
140
+ ---
141
+
142
+ ### 5. 交互时序图(`type: "diagram"`, `diagramType: "sequence"`)
143
+ 带有角色生命线、同步与异步返回箭头的时序图:
144
+ ```json
145
+ {
146
+ "id": "seq1",
147
+ "type": "diagram",
148
+ "props": {
149
+ "diagramType": "sequence",
150
+ "actors": ["User", "Gateway", "DeepSeekAgent", "Database"],
151
+ "steps": [
152
+ { "from": "User", "to": "Gateway", "msg": "发起查询分析" },
153
+ { "from": "Gateway", "to": "DeepSeekAgent", "msg": "调度推理任务" },
154
+ { "from": "DeepSeekAgent", "to": "Database", "msg": "读取知识库" },
155
+ { "from": "Database", "to": "DeepSeekAgent", "msg": "返回上下文数据" },
156
+ { "from": "DeepSeekAgent", "to": "User", "msg": "渲染 GenUI 卡片" }
157
+ ]
158
+ }
159
+ }
160
+ ```
161
+
162
+ ---
163
+
164
+ ### 6. 决策方案对比(`type: "comparison"`)
165
+ 包含横向方案多维评分、优缺点分析、推荐原因以及单选与「确认并采纳此方案」交互提交按钮:
166
+ ```json
167
+ {
168
+ "id": "comp1",
169
+ "type": "comparison",
170
+ "props": {
171
+ "options": [
172
+ {
173
+ "id": "opt_a",
174
+ "name": "方案 A (Redis 缓存加速)",
175
+ "score": 95,
176
+ "pros": ["极低读写延迟 (<2ms)", "高并发承载能力强", "支持丰富数据结构"],
177
+ "cons": ["内存成本较高", "需处理持久化落盘策略"]
178
+ },
179
+ {
180
+ "id": "opt_b",
181
+ "name": "方案 B (PostgreSQL 直读)",
182
+ "score": 82,
183
+ "pros": ["强一致性事务 ACID", "成本相对可控", "开箱即用无额外组件"],
184
+ "cons": ["高并发热点读易造成连接池打满", "P99 延迟较高"]
185
+ }
186
+ ],
187
+ "criteria": ["读写延迟", "高并发表现", "运维成本", "数据一致性"],
188
+ "recommendedOptionId": "opt_a",
189
+ "recommendationReason": "面对 P99 毫秒级高吞吐要求,方案 A 在读性能与吞吐瓶颈突破上具备显著优势。"
190
+ }
191
+ }
192
+ ```
193
+
194
+ ---
195
+
196
+ ### 7. 数据表格(`type: "table"`)
197
+ 支持列定义、字段映射与自动斑马纹排版:
198
+ ```json
199
+ {
200
+ "id": "tbl1",
201
+ "type": "table",
202
+ "props": {
203
+ "title": "活跃微服务节点清单",
204
+ "columns": [
205
+ { "key": "service", "title": "服务名称" },
206
+ { "key": "instances", "title": "实例数" },
207
+ { "key": "qps", "title": "实时 QPS" },
208
+ { "key": "status", "title": "运行状态" }
209
+ ],
210
+ "data": [
211
+ { "service": "order-service", "instances": "8", "qps": "4,200", "status": "🟢 正常" },
212
+ { "service": "auth-center", "instances": "4", "qps": "1,850", "status": "🟢 正常" },
213
+ { "service": "payment-gateway", "instances": "6", "qps": "2,100", "status": "🟡 轻度告警" }
214
+ ]
215
+ }
216
+ }
217
+ ```
218
+
219
+ ---
220
+
221
+ ### 8. 任务进展流水线(`type: "taskPlan"`)
222
+ 支持完成度百分比动态计算、完成/进行中/待处理状态圆点:
223
+ ```json
224
+ {
225
+ "id": "plan1",
226
+ "type": "taskPlan",
227
+ "props": {
228
+ "items": [
229
+ { "id": "t1", "label": "环境准备与凭证鉴权", "status": "completed" },
230
+ { "id": "t2", "label": "分析业务数据与异常日志", "status": "completed" },
231
+ { "id": "t3", "label": "编译并验证 GenUI 模板", "status": "running", "details": "正在流式挂载视图组件..." },
232
+ { "id": "t4", "label": "输出最终决策建议", "status": "pending" }
233
+ ]
234
+ }
235
+ }
236
+ ```
237
+
238
+ ---
239
+
240
+ ### 9. 开发者 UI:代码 Diff 对比(`type: "diff"`)
241
+ 支持 Git 级文件修改对比(绿底增加、红底删除):
242
+ ```json
243
+ {
244
+ "id": "diff1",
245
+ "type": "diff",
246
+ "props": {
247
+ "title": "配置变更审查 (Diff Viewer)",
248
+ "filename": "application-prod.yml",
249
+ "oldCode": "server:\n port: 8080\n timeout: 30s\n max-connections: 1000",
250
+ "newCode": "server:\n port: 8080\n timeout: 60s\n max-connections: 5000\n enable-keepalive: true"
251
+ }
252
+ }
253
+ ```
254
+
255
+ ---
256
+
257
+ ### 10. 结构化概览卡片(`type: "card"`)
258
+ 支持条目清单、图标、分类标签与详细说明(如建议清单、方案总览):
259
+ ```json
260
+ {
261
+ "id": "card_summary",
262
+ "type": "card",
263
+ "props": {
264
+ "title": "建议新增清单",
265
+ "items": [
266
+ {
267
+ "icon": "📦",
268
+ "title": "P0: 基础 UI 与交互原语",
269
+ "tags": ["Markdown", "Text", "List", "Button", "Badge", "Tabs", "Accordion", "Alert"],
270
+ "description": "这是当前最大的基础能力缺口。没有这些组件,模型很难把复杂 UI 组织成清晰、完整的界面。"
271
+ },
272
+ {
273
+ "icon": "🔀",
274
+ "title": "P0: 代码变更与人工审批",
275
+ "tags": ["Diff Viewer", "Patch Preview", "Approval Panel", "Confirmation Dialog"],
276
+ "description": "对于代码 Agent,展示修改前后差异、让用户审查变更、确认高风险操作,比增加更多装饰性图表更有价值。"
277
+ }
278
+ ]
279
+ }
280
+ }
281
+ ```
282
+
283
+ ---
284
+
285
+ ### 11. 交互表单控件(`type: "form"` / `button` / `slider` / `select`)
286
+ 用于向用户收集参数,支持滑块、下拉框、单选与提交按钮:
287
+ ```json
288
+ {
289
+ "id": "f1",
290
+ "type": "form",
291
+ "props": {
292
+ "title": "参数调优控制器",
293
+ "submitText": "立即应用配置",
294
+ "fields": [
295
+ { "name": "concurrency", "label": "最大并发线程数", "type": "number", "placeholder": "16" },
296
+ { "name": "logLevel", "label": "日志级别", "type": "select", "options": [
297
+ { "label": "INFO", "value": "info" },
298
+ { "label": "DEBUG", "value": "debug" },
299
+ { "label": "WARN", "value": "warn" }
300
+ ]}
301
+ ]
302
+ }
303
+ }
304
+ ```
305
+
306
+ ---
307
+
308
+ ## 💡 最佳实践
309
+
310
+ 1. **直接输出代码块**:在回答用户时,不需要让用户去哪里搜索或配置,直接给出 ````agent-genui` 代码块即可。DSH 聊天前端已装配自动渲染拦截器,能将此代码块就地变为交互式卡片。
311
+ 2. **组合使用**:可以使用 `layout: { "type": "stack", "gap": "md" }` 或 `layout: { "type": "grid", "gap": "md" }` 组合多个不同组件(例如:顶部 1 个 `metric` 指标,中间 1 个 `chart` 图表,底部 1 个 `table` 数据表或 `comparison` 方案对比)。
312
+ 3. **保持 JSON 语法严谨**:属性名必须用双引号包裹,字符串内部的引号要转义,避免末尾逗号(trailing comma)。