dsh-share-html 0.2.1 → 0.3.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.
- package/README.md +44 -0
- package/lib/kernel.js +120 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,50 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
|
56
56
|
|
|
57
57
|
**手动改过任一开关后,档位会标为「自定义」**,并且不再高亮任何一档,这样就不会出现「明明改了,顶上还显示对话」的错觉。再点任一档位即恢复该档默认。
|
|
58
58
|
|
|
59
|
+
### 每个开关控制什么
|
|
60
|
+
|
|
61
|
+
| 开关 | 关闭时 | 打开时 |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| **思考过程** | 完全看不到模型推理 | 折叠的「思考过程」块,点开可见推理原文 |
|
|
64
|
+
| **检索结果** | 看不到搜索来源 | 列出检索命中的条目与链接 ⚠️ |
|
|
65
|
+
| **工具调用** | 整段工具交互消失 | 折叠的「工具名 + 参数摘要」 |
|
|
66
|
+
| **工具结果** | 只留一行摘要(`共 3 行 / 52 字符`) | 结果正文全文 |
|
|
67
|
+
| **附件** | 不显示文件条目 | 文件名 + 类型 + 大小(不含内容)|
|
|
68
|
+
| **深度研究** | 不显示深研过程 | 折叠的深研过程块 ⚠️ |
|
|
69
|
+
| **模型信息** | 轮次头只显示状态与耗时 | 轮次头多一个模型名 |
|
|
70
|
+
|
|
71
|
+
> ⚠️ **检索结果 / 深度研究暂时不会产生内容。** 这两个块的渲染与裁剪逻辑都已就位,
|
|
72
|
+
> 但 DSH 的事件流里没有对应的结构化事件 —— 检索结果目前就是普通的工具结果,
|
|
73
|
+
> 深研过程也没有单独事件(DESIGN 里记为待确认项 O2)。所以在真实会话上,
|
|
74
|
+
> 这两个开关拨动不会有可见变化,等 DSH 补上事件形态后接一行投影即可。
|
|
75
|
+
|
|
76
|
+
### 想看三档的实际差别
|
|
77
|
+
|
|
78
|
+
打开 [示例对比页](docs/example-compare.html):同一段会话(排查订单服务超时)用三档各导一次,并排展示。
|
|
79
|
+
|
|
80
|
+
也可以单独打开:
|
|
81
|
+
|
|
82
|
+
- [对话档](docs/example-conversation.html) —— 只有两轮问答
|
|
83
|
+
- [过程档](docs/example-process.html) —— 多出思考、工具调用、附件;工具结果只剩一行摘要
|
|
84
|
+
- [完整档](docs/example-full.html) —— 工具结果全文,轮次头带模型名
|
|
85
|
+
|
|
86
|
+
> 想直观看出区别,请用**用过工具**的会话(让模型读过文件、跑过命令)。只有纯问答的会话,
|
|
87
|
+
> 大部分开关没有可显示的内容,三档看起来会几乎一样 —— 这是正确的,不是开关失灵。
|
|
88
|
+
|
|
89
|
+
### 轮次头
|
|
90
|
+
|
|
91
|
+
每轮的助手输出带一个可折叠的头,与 DSH 原会话一致:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
已完成,用时 9分52秒 ⌄
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- 状态来自 `turn/end` 的 `reason.kind`(已完成 / 已中止 / 失败 / 已取消)
|
|
98
|
+
- 耗时是该轮从开始到结束的实际时长
|
|
99
|
+
- 点击头部可折叠整轮,箭头随状态旋转
|
|
100
|
+
- **默认展开**:导出的是一份要读的记录,不是要点开才知道内容的折叠板
|
|
101
|
+
- 没有 `turn/end` 的会话不显示这一行,也不会留空行
|
|
102
|
+
|
|
59
103
|
### 选择轮次
|
|
60
104
|
|
|
61
105
|
会话很长时,可以只导出其中几轮。展开「导出轮次」后按轮勾选:
|
package/lib/kernel.js
CHANGED
|
@@ -30,10 +30,12 @@ function project(events, options = {}) {
|
|
|
30
30
|
let lastModel;
|
|
31
31
|
const pendingCalls = /* @__PURE__ */ new Map();
|
|
32
32
|
const callOwner = /* @__PURE__ */ new Map();
|
|
33
|
-
const
|
|
33
|
+
const turnStartedAt = /* @__PURE__ */ new Map();
|
|
34
|
+
const openTurn = (user, at) => {
|
|
34
35
|
const turn = { index: turns.length + 1, user, assistants: [] };
|
|
35
36
|
turns.push(turn);
|
|
36
37
|
current = turn;
|
|
38
|
+
if (at !== void 0) turnStartedAt.set(turn.index, at);
|
|
37
39
|
return turn;
|
|
38
40
|
};
|
|
39
41
|
const ensureTurn = () => current ?? openTurn(null);
|
|
@@ -82,7 +84,7 @@ function project(events, options = {}) {
|
|
|
82
84
|
}
|
|
83
85
|
const user = projectUserMessage(msg, at, dropped);
|
|
84
86
|
if (!user) break;
|
|
85
|
-
openTurn(user);
|
|
87
|
+
openTurn(user, at);
|
|
86
88
|
clearStepSlots();
|
|
87
89
|
break;
|
|
88
90
|
}
|
|
@@ -133,7 +135,21 @@ function project(events, options = {}) {
|
|
|
133
135
|
break;
|
|
134
136
|
}
|
|
135
137
|
// ---- 轮次与步骤边界(只影响归并) -----------------------------------
|
|
138
|
+
case "turn/start": {
|
|
139
|
+
if (!current) openTurn(null, at);
|
|
140
|
+
else if (at !== void 0 && !turnStartedAt.has(current.index)) turnStartedAt.set(current.index, at);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
136
143
|
case "turn/end": {
|
|
144
|
+
if (current) {
|
|
145
|
+
const reason = asRecord(data.reason);
|
|
146
|
+
const kind = asString(reason?.kind);
|
|
147
|
+
if (kind) current.status = kind;
|
|
148
|
+
const startedAt = turnStartedAt.get(current.index);
|
|
149
|
+
if (startedAt !== void 0 && at !== void 0 && at >= startedAt) {
|
|
150
|
+
current.durationMs = at - startedAt;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
137
153
|
current = null;
|
|
138
154
|
clearStepSlots();
|
|
139
155
|
break;
|
|
@@ -1669,6 +1685,58 @@ details.process > summary::after {
|
|
|
1669
1685
|
|
|
1670
1686
|
details.process[open] > summary::after { transform: rotate(45deg); }
|
|
1671
1687
|
|
|
1688
|
+
/* ---------- \u8F6E\u6B21\u5934\uFF08\u5DF2\u5B8C\u6210\uFF0C\u7528\u65F6 9\u520652\u79D2\uFF09 ---------- */
|
|
1689
|
+
|
|
1690
|
+
/* \u4E0E .process \u540C\u4E00\u5957\u6298\u53E0\u624B\u611F\uFF1A\u540C\u4E00\u4E2A\u7BAD\u5934\u3001\u540C\u4E00\u5904\u5BF9\u9F50\u3001\u540C\u6837\u53EA\u5728\u60AC\u505C/tab \u65F6\u56DE\u5E94\u3002 */
|
|
1691
|
+
details.turn {
|
|
1692
|
+
margin: 2px 0;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
details.turn > summary.turn-head {
|
|
1696
|
+
display: flex;
|
|
1697
|
+
align-items: center;
|
|
1698
|
+
gap: 10px;
|
|
1699
|
+
min-height: 28px;
|
|
1700
|
+
padding: 2px 0;
|
|
1701
|
+
cursor: pointer;
|
|
1702
|
+
list-style: none;
|
|
1703
|
+
color: var(--dsh-label-tertiary);
|
|
1704
|
+
font-size: 12px;
|
|
1705
|
+
line-height: 18px;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
details.turn > summary.turn-head::-webkit-details-marker { display: none; }
|
|
1709
|
+
|
|
1710
|
+
details.turn > summary.turn-head::after {
|
|
1711
|
+
content: "";
|
|
1712
|
+
flex: none;
|
|
1713
|
+
width: 6px;
|
|
1714
|
+
height: 6px;
|
|
1715
|
+
border-right: 1.5px solid currentColor;
|
|
1716
|
+
border-bottom: 1.5px solid currentColor;
|
|
1717
|
+
transform: rotate(-45deg);
|
|
1718
|
+
transition: transform var(--dsh-duration-fast) var(--dsh-ease-in-out);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
details.turn[open] > summary.turn-head::after { transform: rotate(45deg); }
|
|
1722
|
+
|
|
1723
|
+
.turn-head .turn-meta { font-variant-numeric: tabular-nums; }
|
|
1724
|
+
.turn-head .msg-model { color: var(--dsh-label-caption); }
|
|
1725
|
+
|
|
1726
|
+
details.turn > summary.turn-head:focus-visible {
|
|
1727
|
+
outline: 1.5px solid var(--dsh-link);
|
|
1728
|
+
outline-offset: 2px;
|
|
1729
|
+
border-radius: var(--dsh-radius-sm);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
@media (hover: hover) {
|
|
1733
|
+
details.turn > summary.turn-head:hover { color: var(--dsh-label-secondary); }
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
/* \u5C55\u5F00\u540E\u6B63\u6587\u4E0E\u5934\u90E8\u5DE6\u8FB9\u7F18\u5BF9\u9F50\uFF0C\u4E0D\u989D\u5916\u7F29\u8FDB\uFF08\u8FD9\u4E00\u5C42\u4E0D\u662F"\u8FC7\u7A0B"\u7684\u5B50\u9879\uFF09 */
|
|
1737
|
+
.turn-body { margin: 2px 0 0; }
|
|
1738
|
+
.turn-body > *:first-child { margin-top: 0; }
|
|
1739
|
+
|
|
1672
1740
|
@media (hover: hover) {
|
|
1673
1741
|
details.process > summary:hover { color: var(--dsh-label-secondary); }
|
|
1674
1742
|
}
|
|
@@ -2021,11 +2089,7 @@ function renderHtml(model, meta = {}) {
|
|
|
2021
2089
|
assistantBlocks.push(renderAssistantMessage(msg));
|
|
2022
2090
|
}
|
|
2023
2091
|
if (assistantBlocks.length) {
|
|
2024
|
-
|
|
2025
|
-
` : "";
|
|
2026
|
-
body.push(`<article class="msg" data-role="assistant">
|
|
2027
|
-
${head}${assistantBlocks.join("\n")}
|
|
2028
|
-
</article>`);
|
|
2092
|
+
body.push(renderTurnArticle(turn, assistantBlocks, turnModels));
|
|
2029
2093
|
}
|
|
2030
2094
|
}
|
|
2031
2095
|
if (!body.length) {
|
|
@@ -2130,6 +2194,27 @@ function renderUserMessage(msg) {
|
|
|
2130
2194
|
${parts.join("\n")}
|
|
2131
2195
|
</article>`;
|
|
2132
2196
|
}
|
|
2197
|
+
function renderTurnArticle(turn, blocks, models) {
|
|
2198
|
+
const status = statusLabel(turn.status);
|
|
2199
|
+
const duration = turn.durationMs !== void 0 ? formatDuration(turn.durationMs) : "";
|
|
2200
|
+
const metaParts = [status, duration ? `\u7528\u65F6 ${duration}` : ""].filter(Boolean);
|
|
2201
|
+
const metaHtml = metaParts.length ? `<span class="turn-meta">${esc(metaParts.join("\uFF0C"))}</span>` : "";
|
|
2202
|
+
const modelHtml = models.length ? `<span class="msg-model">${models.map(esc).join(" \xB7 ")}</span>` : "";
|
|
2203
|
+
const head = metaHtml || modelHtml ? `<summary class="turn-head">${metaHtml}${modelHtml}</summary>
|
|
2204
|
+
` : "";
|
|
2205
|
+
if (!head) {
|
|
2206
|
+
return `<article class="msg" data-role="assistant">
|
|
2207
|
+
${blocks.join("\n")}
|
|
2208
|
+
</article>`;
|
|
2209
|
+
}
|
|
2210
|
+
return `<article class="msg" data-role="assistant">
|
|
2211
|
+
<details class="turn" open>
|
|
2212
|
+
${head}<div class="turn-body">
|
|
2213
|
+
${blocks.join("\n")}
|
|
2214
|
+
</div>
|
|
2215
|
+
</details>
|
|
2216
|
+
</article>`;
|
|
2217
|
+
}
|
|
2133
2218
|
function renderAssistantMessage(msg) {
|
|
2134
2219
|
const parts = [];
|
|
2135
2220
|
for (const block of msg.blocks) {
|
|
@@ -2266,6 +2351,33 @@ function formatBytes(bytes) {
|
|
|
2266
2351
|
}
|
|
2267
2352
|
return `${value >= 10 ? Math.round(value) : value.toFixed(1)} ${units[unit]}`;
|
|
2268
2353
|
}
|
|
2354
|
+
function formatDuration(ms) {
|
|
2355
|
+
if (!Number.isFinite(ms) || ms < 0) return "";
|
|
2356
|
+
const totalSeconds = Math.floor(ms / 1e3);
|
|
2357
|
+
if (totalSeconds < 1) return "\u4E0D\u8DB31\u79D2";
|
|
2358
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
2359
|
+
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
2360
|
+
const seconds = totalSeconds % 60;
|
|
2361
|
+
if (hours > 0) return `${hours}\u5C0F\u65F6${minutes}\u5206${seconds}\u79D2`;
|
|
2362
|
+
if (minutes > 0) return `${minutes}\u5206${seconds}\u79D2`;
|
|
2363
|
+
return `${seconds}\u79D2`;
|
|
2364
|
+
}
|
|
2365
|
+
function statusLabel(status) {
|
|
2366
|
+
switch (status) {
|
|
2367
|
+
case "completed":
|
|
2368
|
+
return "\u5DF2\u5B8C\u6210";
|
|
2369
|
+
case "aborted":
|
|
2370
|
+
return "\u5DF2\u4E2D\u6B62";
|
|
2371
|
+
case "failed":
|
|
2372
|
+
return "\u5931\u8D25";
|
|
2373
|
+
case "cancelled":
|
|
2374
|
+
return "\u5DF2\u53D6\u6D88";
|
|
2375
|
+
case void 0:
|
|
2376
|
+
return "";
|
|
2377
|
+
default:
|
|
2378
|
+
return status;
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2269
2381
|
function presetLabel(preset) {
|
|
2270
2382
|
switch (preset) {
|
|
2271
2383
|
case "conversation":
|
|
@@ -2336,7 +2448,7 @@ function filenameStamp(epochMs, timeZone) {
|
|
|
2336
2448
|
}
|
|
2337
2449
|
|
|
2338
2450
|
// src/host/index.ts
|
|
2339
|
-
var VERSION = "0.
|
|
2451
|
+
var VERSION = "0.3.0";
|
|
2340
2452
|
function exportSession(input) {
|
|
2341
2453
|
const preset = input.preset ?? "conversation";
|
|
2342
2454
|
const opts = shareOptions(preset, input.options ?? {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-share-html",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Export a DSH session as one self-contained, offline HTML file that looks like the original conversation: three detail presets, per-block switches, built-in redaction, zero scripts and zero external requests.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|