dsh-share-html 0.4.0 → 0.5.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 +2 -16
- package/lib/kernel.js +19 -183
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
|
64
64
|
| **工具调用** | 整段工具交互消失 | 折叠的「工具名 + 参数摘要」 |
|
|
65
65
|
| **工具结果** | 只留一行摘要(`共 3 行 / 52 字符`) | 结果正文全文 |
|
|
66
66
|
| **附件** | 不显示文件条目 | 文件名 + 类型 + 大小(不含内容)|
|
|
67
|
-
| **模型信息** |
|
|
67
|
+
| **模型信息** | 消息头部不显示模型名 | 消息头部左侧显示模型名 |
|
|
68
68
|
|
|
69
69
|
> **关于「检索结果」和「深度研究」**:这两个开关曾经存在,v0.3.1 起已从界面上移除。
|
|
70
70
|
> 它们的渲染与裁剪逻辑都已写好,但 DSH 的事件流里没有对应的结构化事件 ——
|
|
@@ -80,25 +80,11 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
|
80
80
|
|
|
81
81
|
- [对话档](docs/example-conversation.html) —— 只有两轮问答
|
|
82
82
|
- [过程档](docs/example-process.html) —— 多出思考、工具调用、附件;工具结果只剩一行摘要
|
|
83
|
-
- [完整档](docs/example-full.html) ——
|
|
83
|
+
- [完整档](docs/example-full.html) —— 工具结果全文,消息头带模型名
|
|
84
84
|
|
|
85
85
|
> 想直观看出区别,请用**用过工具**的会话(让模型读过文件、跑过命令)。只有纯问答的会话,
|
|
86
86
|
> 大部分开关没有可显示的内容,三档看起来会几乎一样 —— 这是正确的,不是开关失灵。
|
|
87
87
|
|
|
88
|
-
### 轮次头
|
|
89
|
-
|
|
90
|
-
每轮的助手输出带一个可折叠的头,与 DSH 原会话一致:
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
已完成,用时 9分52秒 ⌄
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
- 状态来自 `turn/end` 的 `reason.kind`(已完成 / 已中止 / 失败 / 已取消)
|
|
97
|
-
- 耗时是该轮从开始到结束的实际时长
|
|
98
|
-
- 点击头部可折叠整轮,箭头随状态旋转
|
|
99
|
-
- **默认展开**:导出的是一份要读的记录,不是要点开才知道内容的折叠板
|
|
100
|
-
- 没有 `turn/end` 的会话不显示这一行,也不会留空行
|
|
101
|
-
|
|
102
88
|
### 选择轮次
|
|
103
89
|
|
|
104
90
|
会话很长时,可以只导出其中几轮。展开「导出轮次」后按轮勾选:
|
package/lib/kernel.js
CHANGED
|
@@ -30,12 +30,10 @@ function project(events, options = {}) {
|
|
|
30
30
|
let lastModel;
|
|
31
31
|
const pendingCalls = /* @__PURE__ */ new Map();
|
|
32
32
|
const callOwner = /* @__PURE__ */ new Map();
|
|
33
|
-
const
|
|
34
|
-
const openTurn = (user, at) => {
|
|
33
|
+
const openTurn = (user) => {
|
|
35
34
|
const turn = { index: turns.length + 1, user, assistants: [] };
|
|
36
35
|
turns.push(turn);
|
|
37
36
|
current = turn;
|
|
38
|
-
if (at !== void 0) turnStartedAt.set(turn.index, at);
|
|
39
37
|
return turn;
|
|
40
38
|
};
|
|
41
39
|
const ensureTurn = () => current ?? openTurn(null);
|
|
@@ -84,7 +82,7 @@ function project(events, options = {}) {
|
|
|
84
82
|
}
|
|
85
83
|
const user = projectUserMessage(msg, at, dropped);
|
|
86
84
|
if (!user) break;
|
|
87
|
-
openTurn(user
|
|
85
|
+
openTurn(user);
|
|
88
86
|
clearStepSlots();
|
|
89
87
|
break;
|
|
90
88
|
}
|
|
@@ -135,21 +133,7 @@ function project(events, options = {}) {
|
|
|
135
133
|
break;
|
|
136
134
|
}
|
|
137
135
|
// ---- 轮次与步骤边界(只影响归并) -----------------------------------
|
|
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
|
-
}
|
|
143
136
|
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
|
-
}
|
|
153
137
|
current = null;
|
|
154
138
|
clearStepSlots();
|
|
155
139
|
break;
|
|
@@ -1685,88 +1669,6 @@ details.process > summary::after {
|
|
|
1685
1669
|
|
|
1686
1670
|
details.process[open] > summary::after { transform: rotate(45deg); }
|
|
1687
1671
|
|
|
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
|
-
|
|
1740
|
-
/* ---------- \u8FC7\u7A0B\u5757\u5185\u7684\u6241\u5E73\u5185\u5BB9 ---------- */
|
|
1741
|
-
/* \u5DF2\u7ECF\u5728\u300C\u8FC7\u7A0B\u300D\u6298\u53E0\u91CC\u4E86\uFF0C\u5C31\u4E0D\u518D\u5957\u7B2C\u4E8C\u5C42 <details>\uFF1A
|
|
1742
|
-
\u5426\u5219\u8BFB\u4E00\u884C\u8F93\u51FA\u8981\u70B9\u4E09\u6B21\uFF08\u8F6E\u6B21 \u2192 \u8FC7\u7A0B \u2192 \u5DE5\u5177\uFF09\u3002 */
|
|
1743
|
-
.flat-block {
|
|
1744
|
-
margin: 6px 0;
|
|
1745
|
-
padding-left: 22px;
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
.flat-head {
|
|
1749
|
-
display: flex;
|
|
1750
|
-
align-items: center;
|
|
1751
|
-
gap: 8px;
|
|
1752
|
-
font-size: 12px;
|
|
1753
|
-
line-height: 18px;
|
|
1754
|
-
color: var(--dsh-label-tertiary);
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
.flat-head .sum-name {
|
|
1758
|
-
color: var(--dsh-label-secondary);
|
|
1759
|
-
font-family: var(--dsh-font-code);
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
.flat-body {
|
|
1763
|
-
margin: 2px 0 0;
|
|
1764
|
-
overflow-wrap: anywhere;
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
|
-
.flat-body > *:first-child { margin-top: 0; }
|
|
1768
|
-
.flat-body > *:last-child { margin-bottom: 0; }
|
|
1769
|
-
|
|
1770
1672
|
@media (hover: hover) {
|
|
1771
1673
|
details.process > summary:hover { color: var(--dsh-label-secondary); }
|
|
1772
1674
|
}
|
|
@@ -2111,20 +2013,19 @@ function renderHtml(model, meta = {}) {
|
|
|
2111
2013
|
body.push(renderUserMessage(turn.user));
|
|
2112
2014
|
}
|
|
2113
2015
|
const assistantBlocks = [];
|
|
2114
|
-
const stepBlocks = [];
|
|
2115
2016
|
const turnModels = [];
|
|
2116
|
-
const
|
|
2117
|
-
for (const [i, msg] of turn.assistants.entries()) {
|
|
2017
|
+
for (const msg of turn.assistants) {
|
|
2118
2018
|
stats.messages += 1;
|
|
2119
2019
|
stats.toolCalls += msg.blocks.filter((b) => b.kind === "tool").length;
|
|
2120
2020
|
if (msg.model && !turnModels.includes(msg.model)) turnModels.push(msg.model);
|
|
2121
|
-
|
|
2122
|
-
if (!rendered) continue;
|
|
2123
|
-
if (i === lastIndex) assistantBlocks.push(rendered);
|
|
2124
|
-
else if (rendered.trim()) stepBlocks.push(rendered);
|
|
2021
|
+
assistantBlocks.push(renderAssistantMessage(msg));
|
|
2125
2022
|
}
|
|
2126
|
-
if (assistantBlocks.length
|
|
2127
|
-
|
|
2023
|
+
if (assistantBlocks.length) {
|
|
2024
|
+
const head = turnModels.length ? `<header class="msg-head"><span class="msg-model">${turnModels.map(esc).join(" \xB7 ")}</span></header>
|
|
2025
|
+
` : "";
|
|
2026
|
+
body.push(`<article class="msg" data-role="assistant">
|
|
2027
|
+
${head}${assistantBlocks.join("\n")}
|
|
2028
|
+
</article>`);
|
|
2128
2029
|
}
|
|
2129
2030
|
}
|
|
2130
2031
|
if (!body.length) {
|
|
@@ -2229,41 +2130,14 @@ function renderUserMessage(msg) {
|
|
|
2229
2130
|
${parts.join("\n")}
|
|
2230
2131
|
</article>`;
|
|
2231
2132
|
}
|
|
2232
|
-
function
|
|
2233
|
-
const status = statusLabel(turn.status);
|
|
2234
|
-
const duration = turn.durationMs !== void 0 ? formatDuration(turn.durationMs) : "";
|
|
2235
|
-
const metaParts = [status, duration ? `\u7528\u65F6 ${duration}` : ""].filter(Boolean);
|
|
2236
|
-
const metaHtml = metaParts.length ? `<span class="turn-meta">${esc(metaParts.join("\uFF0C"))}</span>` : "";
|
|
2237
|
-
const modelHtml = models.length ? `<span class="msg-model">${models.map(esc).join(" \xB7 ")}</span>` : "";
|
|
2238
|
-
const processHtml = stepBlocks.length ? renderDetails({
|
|
2239
|
-
kind: "steps",
|
|
2240
|
-
summary: `\u8FC7\u7A0B\uFF08${stepBlocks.length} \u6B65\uFF09`,
|
|
2241
|
-
body: stepBlocks.join("\n"),
|
|
2242
|
-
open: false
|
|
2243
|
-
}) : "";
|
|
2244
|
-
const inner = [processHtml, ...answerBlocks].filter(Boolean).join("\n");
|
|
2245
|
-
if (!metaHtml && !modelHtml) {
|
|
2246
|
-
return `<article class="msg" data-role="assistant">
|
|
2247
|
-
${inner}
|
|
2248
|
-
</article>`;
|
|
2249
|
-
}
|
|
2250
|
-
return `<article class="msg" data-role="assistant">
|
|
2251
|
-
<details class="turn" open>
|
|
2252
|
-
<summary class="turn-head">${metaHtml}${modelHtml}</summary>
|
|
2253
|
-
<div class="turn-body">
|
|
2254
|
-
${inner}
|
|
2255
|
-
</div>
|
|
2256
|
-
</details>
|
|
2257
|
-
</article>`;
|
|
2258
|
-
}
|
|
2259
|
-
function renderAssistantMessage(msg, flat = false) {
|
|
2133
|
+
function renderAssistantMessage(msg) {
|
|
2260
2134
|
const parts = [];
|
|
2261
2135
|
for (const block of msg.blocks) {
|
|
2262
|
-
parts.push(renderBlock(block
|
|
2136
|
+
parts.push(renderBlock(block));
|
|
2263
2137
|
}
|
|
2264
2138
|
return parts.filter(Boolean).join("\n");
|
|
2265
2139
|
}
|
|
2266
|
-
function renderBlock(block
|
|
2140
|
+
function renderBlock(block) {
|
|
2267
2141
|
switch (block.kind) {
|
|
2268
2142
|
case "text":
|
|
2269
2143
|
return `<div class="md">${renderMarkdown(block.md)}</div>`;
|
|
@@ -2271,11 +2145,10 @@ function renderBlock(block, flat = false) {
|
|
|
2271
2145
|
return renderDetails({
|
|
2272
2146
|
kind: "reasoning",
|
|
2273
2147
|
summary: "\u601D\u8003\u8FC7\u7A0B",
|
|
2274
|
-
body: `<div class="md">${renderMarkdown(block.text)}</div
|
|
2275
|
-
open: flat
|
|
2148
|
+
body: `<div class="md">${renderMarkdown(block.text)}</div>`
|
|
2276
2149
|
});
|
|
2277
2150
|
case "tool":
|
|
2278
|
-
return renderTool(block
|
|
2151
|
+
return renderTool(block);
|
|
2279
2152
|
case "retrieval":
|
|
2280
2153
|
return renderRetrieval(block);
|
|
2281
2154
|
case "research":
|
|
@@ -2293,8 +2166,7 @@ function renderBlock(block, flat = false) {
|
|
|
2293
2166
|
function renderDetails(input) {
|
|
2294
2167
|
const statusAttr = input.status ? ` data-status="${esc(input.status)}"` : "";
|
|
2295
2168
|
const nameHtml = input.name ? `<span class="sum-name">${esc(input.name)}</span>` : "";
|
|
2296
|
-
|
|
2297
|
-
return `<details class="process" data-kind="${esc(input.kind)}"${openAttr}>
|
|
2169
|
+
return `<details class="process" data-kind="${esc(input.kind)}">
|
|
2298
2170
|
<summary><span class="sum-text">${esc(input.summary)}</span>${nameHtml}${statusDot(input.status)}</summary>
|
|
2299
2171
|
<div class="process-body">
|
|
2300
2172
|
${input.body}
|
|
@@ -2307,7 +2179,7 @@ function statusDot(status) {
|
|
|
2307
2179
|
if (status === "pending") return '<span class="sum-state" data-status="pending">\u672A\u5B8C\u6210</span>';
|
|
2308
2180
|
return "";
|
|
2309
2181
|
}
|
|
2310
|
-
function renderTool(block
|
|
2182
|
+
function renderTool(block) {
|
|
2311
2183
|
const summaryText = toolSummary(block);
|
|
2312
2184
|
const body = [];
|
|
2313
2185
|
if (block.argsFields?.length) {
|
|
@@ -2329,17 +2201,8 @@ function renderTool(block, flat = false) {
|
|
|
2329
2201
|
body.push('<div class="trunc-note">\u4F1A\u8BDD\u5BFC\u51FA\u65F6\u8BE5\u8C03\u7528\u5C1A\u672A\u8FD4\u56DE</div>');
|
|
2330
2202
|
}
|
|
2331
2203
|
const stateText = block.status === "error" ? "\u5931\u8D25" : block.status === "pending" ? "\u672A\u5B8C\u6210" : "";
|
|
2332
|
-
const head = `<span class="sum-name">${esc(block.name)}</span><span class="sum-dot"></span><span class="sum-text">${esc(summaryText)}</span>${stateText ? `<span class="sum-state" data-status="${esc(block.status)}">${esc(stateText)}</span>` : ""}`;
|
|
2333
|
-
if (flat) {
|
|
2334
|
-
return `<div class="flat-block" data-kind="tool" data-tool="${esc(block.name)}">
|
|
2335
|
-
<div class="flat-head">${head}</div>
|
|
2336
|
-
<div class="flat-body">
|
|
2337
|
-
${body.join("\n")}
|
|
2338
|
-
</div>
|
|
2339
|
-
</div>`;
|
|
2340
|
-
}
|
|
2341
2204
|
return `<details class="process" data-kind="tool" data-tool="${esc(block.name)}">
|
|
2342
|
-
<summary>${
|
|
2205
|
+
<summary><span class="sum-name">${esc(block.name)}</span><span class="sum-dot"></span><span class="sum-text">${esc(summaryText)}</span>${stateText ? `<span class="sum-state" data-status="${esc(block.status)}">${esc(stateText)}</span>` : ""}</summary>
|
|
2343
2206
|
<div class="process-body">
|
|
2344
2207
|
${body.join("\n")}
|
|
2345
2208
|
</div>
|
|
@@ -2403,33 +2266,6 @@ function formatBytes(bytes) {
|
|
|
2403
2266
|
}
|
|
2404
2267
|
return `${value >= 10 ? Math.round(value) : value.toFixed(1)} ${units[unit]}`;
|
|
2405
2268
|
}
|
|
2406
|
-
function formatDuration(ms) {
|
|
2407
|
-
if (!Number.isFinite(ms) || ms < 0) return "";
|
|
2408
|
-
const totalSeconds = Math.floor(ms / 1e3);
|
|
2409
|
-
if (totalSeconds < 1) return "\u4E0D\u8DB31\u79D2";
|
|
2410
|
-
const hours = Math.floor(totalSeconds / 3600);
|
|
2411
|
-
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
2412
|
-
const seconds = totalSeconds % 60;
|
|
2413
|
-
if (hours > 0) return `${hours}\u5C0F\u65F6${minutes}\u5206${seconds}\u79D2`;
|
|
2414
|
-
if (minutes > 0) return `${minutes}\u5206${seconds}\u79D2`;
|
|
2415
|
-
return `${seconds}\u79D2`;
|
|
2416
|
-
}
|
|
2417
|
-
function statusLabel(status) {
|
|
2418
|
-
switch (status) {
|
|
2419
|
-
case "completed":
|
|
2420
|
-
return "\u5DF2\u5B8C\u6210";
|
|
2421
|
-
case "aborted":
|
|
2422
|
-
return "\u5DF2\u4E2D\u6B62";
|
|
2423
|
-
case "failed":
|
|
2424
|
-
return "\u5931\u8D25";
|
|
2425
|
-
case "cancelled":
|
|
2426
|
-
return "\u5DF2\u53D6\u6D88";
|
|
2427
|
-
case void 0:
|
|
2428
|
-
return "";
|
|
2429
|
-
default:
|
|
2430
|
-
return status;
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
2269
|
function presetLabel(preset) {
|
|
2434
2270
|
switch (preset) {
|
|
2435
2271
|
case "conversation":
|
|
@@ -2500,7 +2336,7 @@ function filenameStamp(epochMs, timeZone) {
|
|
|
2500
2336
|
}
|
|
2501
2337
|
|
|
2502
2338
|
// src/host/index.ts
|
|
2503
|
-
var VERSION = "0.
|
|
2339
|
+
var VERSION = "0.5.0";
|
|
2504
2340
|
function exportSession(input) {
|
|
2505
2341
|
const preset = input.preset ?? "conversation";
|
|
2506
2342
|
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.5.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",
|