@leeoohoo/ui-apps-devkit 0.1.7 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leeoohoo/ui-apps-devkit",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "ChatOS UI Apps DevKit (CLI + templates + sandbox) for building installable ChatOS UI Apps plugins.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1407,6 +1407,7 @@ function renderPrompts() {
1407
1407
  form.style.gap = '10px';
1408
1408
 
1409
1409
  const kind = String(req?.prompt?.kind || '');
1410
+ const allowCancel = req?.prompt?.allowCancel !== false;
1410
1411
 
1411
1412
  const mkBtn = (label, danger) => {
1412
1413
  const btn = document.createElement('button');
@@ -1421,7 +1422,31 @@ function renderPrompts() {
1421
1422
  emitUpdate();
1422
1423
  };
1423
1424
 
1424
- if (kind === 'kv') {
1425
+ if (kind === 'result') {
1426
+ const markdownText =
1427
+ typeof req?.prompt?.markdown === 'string'
1428
+ ? req.prompt.markdown
1429
+ : typeof req?.prompt?.result === 'string'
1430
+ ? req.prompt.result
1431
+ : typeof req?.prompt?.content === 'string'
1432
+ ? req.prompt.content
1433
+ : '';
1434
+ const markdown = document.createElement('pre');
1435
+ markdown.className = 'mono';
1436
+ markdown.textContent = markdownText || '(无结果内容)';
1437
+ form.appendChild(markdown);
1438
+ const row = document.createElement('div');
1439
+ row.className = 'row';
1440
+ const ok = mkBtn('OK');
1441
+ ok.addEventListener('click', () => submit({ status: 'ok' }));
1442
+ row.appendChild(ok);
1443
+ if (allowCancel) {
1444
+ const cancel = mkBtn('Cancel', true);
1445
+ cancel.addEventListener('click', () => submit({ status: 'cancel' }));
1446
+ row.appendChild(cancel);
1447
+ }
1448
+ form.appendChild(row);
1449
+ } else if (kind === 'kv') {
1425
1450
  const fields = Array.isArray(req?.prompt?.fields) ? req.prompt.fields : [];
1426
1451
  const values = {};
1427
1452
  for (const f of fields) {
@@ -1443,10 +1468,12 @@ function renderPrompts() {
1443
1468
  row.className = 'row';
1444
1469
  const ok = mkBtn('Submit');
1445
1470
  ok.addEventListener('click', () => submit({ status: 'ok', values }));
1446
- const cancel = mkBtn('Cancel', true);
1447
- cancel.addEventListener('click', () => submit({ status: 'cancel' }));
1448
1471
  row.appendChild(ok);
1449
- row.appendChild(cancel);
1472
+ if (allowCancel) {
1473
+ const cancel = mkBtn('Cancel', true);
1474
+ cancel.addEventListener('click', () => submit({ status: 'cancel' }));
1475
+ row.appendChild(cancel);
1476
+ }
1450
1477
  form.appendChild(row);
1451
1478
  } else if (kind === 'choice') {
1452
1479
  const options = Array.isArray(req?.prompt?.options) ? req.prompt.options : [];
@@ -1475,20 +1502,24 @@ function renderPrompts() {
1475
1502
  row.className = 'row';
1476
1503
  const ok = mkBtn('Submit');
1477
1504
  ok.addEventListener('click', () => submit({ status: 'ok', value: multiple ? Array.from(selected) : Array.from(selected)[0] || '' }));
1478
- const cancel = mkBtn('Cancel', true);
1479
- cancel.addEventListener('click', () => submit({ status: 'cancel' }));
1480
1505
  row.appendChild(ok);
1481
- row.appendChild(cancel);
1506
+ if (allowCancel) {
1507
+ const cancel = mkBtn('Cancel', true);
1508
+ cancel.addEventListener('click', () => submit({ status: 'cancel' }));
1509
+ row.appendChild(cancel);
1510
+ }
1482
1511
  form.appendChild(row);
1483
1512
  } else {
1484
1513
  const row = document.createElement('div');
1485
1514
  row.className = 'row';
1486
1515
  const ok = mkBtn('OK');
1487
1516
  ok.addEventListener('click', () => submit({ status: 'ok' }));
1488
- const cancel = mkBtn('Cancel', true);
1489
- cancel.addEventListener('click', () => submit({ status: 'cancel' }));
1490
1517
  row.appendChild(ok);
1491
- row.appendChild(cancel);
1518
+ if (allowCancel) {
1519
+ const cancel = mkBtn('Cancel', true);
1520
+ cancel.addEventListener('click', () => submit({ status: 'cancel' }));
1521
+ row.appendChild(cancel);
1522
+ }
1492
1523
  form.appendChild(row);
1493
1524
  }
1494
1525
 
@@ -6,7 +6,7 @@ UI Prompts 是 ChatOS 的全局交互队列:任意组件(AI / MCP / UI Apps
6
6
 
7
7
  - 存储格式:`ui-prompts.jsonl`(JSON Lines 追加日志)
8
8
  - 交互生命周期:`request` → `response`
9
- - UI 渲染支持的 `prompt.kind` 与字段(`kv` / `choice` / `task_confirm` / `file_change_confirm`)
9
+ - UI 渲染支持的 `prompt.kind` 与字段(`kv` / `choice` / `task_confirm` / `file_change_confirm` / `result`)
10
10
  - UI Apps 的 Host API 调用方式(`host.uiPrompts.*`)
11
11
 
12
12
  实现对照(以代码为准):
@@ -146,7 +146,7 @@ UI Apps 的 `module` 应用通过 Host API 与 UI Prompts 交互:
146
146
 
147
147
  | 字段 | 类型 | 必填 | 说明 |
148
148
  |---|---:|---:|---|
149
- | `kind` | `string` | 是 | 取值:`kv` / `choice` / `task_confirm` / `file_change_confirm` |
149
+ | `kind` | `string` | 是 | 取值:`kv` / `choice` / `task_confirm` / `file_change_confirm` / `result` |
150
150
  | `title` | `string` | 否 | UI 标题 |
151
151
  | `message` | `string` | 否 | UI 描述/说明 |
152
152
  | `source` | `string` | 否 | 来源标识(UI 显示 Tag) |
@@ -376,7 +376,36 @@ UI 渲染规则:
376
376
 
377
377
  ---
378
378
 
379
- ## 9. 复杂交互的构建方式
379
+ ## 9. `kind="result"`:执行结果(Markdown 展示)
380
+
381
+ 该类型用于“执行完成后的结果通知”。UI 会以 Markdown 形式展示结果,并在用户确认后写入 `response`。
382
+
383
+ ### 9.1 请求结构
384
+
385
+ ```json
386
+ {
387
+ "kind": "result",
388
+ "title": "执行结果",
389
+ "message": "已完成全部步骤。",
390
+ "source": "com.example.plugin:my-app",
391
+ "allowCancel": true,
392
+ "markdown": "## Done\n- step 1\n- step 2"
393
+ }
394
+ ```
395
+
396
+ 字段:
397
+
398
+ - `markdown`:可选字符串;作为 Markdown 内容展示
399
+
400
+ ### 9.2 响应结构
401
+
402
+ ```json
403
+ { "status": "ok" }
404
+ ```
405
+
406
+ ---
407
+
408
+ ## 10. 复杂交互的构建方式
380
409
 
381
410
  UI Prompts 的基本单位是一条 `request` 记录。复杂交互由多条 `request/response` 串联构成:
382
411
 
@@ -390,3 +419,4 @@ UI Prompts 的基本单位是一条 `request` 记录。复杂交互由多条 `re
390
419
  - “多选/单选”使用 `kind="choice"` 的 `multiple/options` 承载
391
420
  - “任务列表确认”使用 `kind="task_confirm"` 承载
392
421
  - “diff/命令确认”使用 `kind="file_change_confirm"` 承载
422
+ - “执行结果通知”使用 `kind="result"` 承载
@@ -6,7 +6,7 @@ UI Prompts 是 ChatOS 的全局交互队列:任意组件(AI / MCP / UI Apps
6
6
 
7
7
  - 存储格式:`ui-prompts.jsonl`(JSON Lines 追加日志)
8
8
  - 交互生命周期:`request` → `response`
9
- - UI 渲染支持的 `prompt.kind` 与字段(`kv` / `choice` / `task_confirm` / `file_change_confirm`)
9
+ - UI 渲染支持的 `prompt.kind` 与字段(`kv` / `choice` / `task_confirm` / `file_change_confirm` / `result`)
10
10
  - UI Apps 的 Host API 调用方式(`host.uiPrompts.*`)
11
11
 
12
12
  实现对照(以代码为准):
@@ -146,7 +146,7 @@ UI Apps 的 `module` 应用通过 Host API 与 UI Prompts 交互:
146
146
 
147
147
  | 字段 | 类型 | 必填 | 说明 |
148
148
  |---|---:|---:|---|
149
- | `kind` | `string` | 是 | 取值:`kv` / `choice` / `task_confirm` / `file_change_confirm` |
149
+ | `kind` | `string` | 是 | 取值:`kv` / `choice` / `task_confirm` / `file_change_confirm` / `result` |
150
150
  | `title` | `string` | 否 | UI 标题 |
151
151
  | `message` | `string` | 否 | UI 描述/说明 |
152
152
  | `source` | `string` | 否 | 来源标识(UI 显示 Tag) |
@@ -376,7 +376,36 @@ UI 渲染规则:
376
376
 
377
377
  ---
378
378
 
379
- ## 9. 复杂交互的构建方式
379
+ ## 9. `kind="result"`:执行结果(Markdown 展示)
380
+
381
+ 该类型用于“执行完成后的结果通知”。UI 会以 Markdown 形式展示结果,并在用户确认后写入 `response`。
382
+
383
+ ### 9.1 请求结构
384
+
385
+ ```json
386
+ {
387
+ "kind": "result",
388
+ "title": "执行结果",
389
+ "message": "已完成全部步骤。",
390
+ "source": "com.example.plugin:my-app",
391
+ "allowCancel": true,
392
+ "markdown": "## Done\n- step 1\n- step 2"
393
+ }
394
+ ```
395
+
396
+ 字段:
397
+
398
+ - `markdown`:可选字符串;作为 Markdown 内容展示
399
+
400
+ ### 9.2 响应结构
401
+
402
+ ```json
403
+ { "status": "ok" }
404
+ ```
405
+
406
+ ---
407
+
408
+ ## 10. 复杂交互的构建方式
380
409
 
381
410
  UI Prompts 的基本单位是一条 `request` 记录。复杂交互由多条 `request/response` 串联构成:
382
411
 
@@ -390,3 +419,4 @@ UI Prompts 的基本单位是一条 `request` 记录。复杂交互由多条 `re
390
419
  - “多选/单选”使用 `kind="choice"` 的 `multiple/options` 承载
391
420
  - “任务列表确认”使用 `kind="task_confirm"` 承载
392
421
  - “diff/命令确认”使用 `kind="file_change_confirm"` 承载
422
+ - “执行结果通知”使用 `kind="result"` 承载