dsh-share-html 0.4.1 → 0.5.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/README.md +6 -34
- package/lib/index.js +17 -2
- package/lib/kernel.js +191 -232
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 会话导出插件** —— 把一次对话导出成**单个自包含 HTML 文件**,观感与原会话一致,双击即可离线打开。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
存档复盘、交付会话、贴进 wiki,都不用再截图拼接。
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
|
|
17
17
|
## 安装
|
|
18
18
|
|
|
19
|
+
> 完整安装指引(含排错、与同类插件的对比)见 **[INSTALL.md](INSTALL.md)**。
|
|
20
|
+
|
|
21
|
+
|
|
19
22
|
```bash
|
|
20
23
|
dsh plugin --profile web add dsh-share-html
|
|
21
24
|
```
|
|
@@ -64,7 +67,7 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
|
64
67
|
| **工具调用** | 整段工具交互消失 | 折叠的「工具名 + 参数摘要」 |
|
|
65
68
|
| **工具结果** | 只留一行摘要(`共 3 行 / 52 字符`) | 结果正文全文 |
|
|
66
69
|
| **附件** | 不显示文件条目 | 文件名 + 类型 + 大小(不含内容)|
|
|
67
|
-
| **模型信息** |
|
|
70
|
+
| **模型信息** | 消息头部不显示模型名 | 消息头部左侧显示模型名 |
|
|
68
71
|
|
|
69
72
|
> **关于「检索结果」和「深度研究」**:这两个开关曾经存在,v0.3.1 起已从界面上移除。
|
|
70
73
|
> 它们的渲染与裁剪逻辑都已写好,但 DSH 的事件流里没有对应的结构化事件 ——
|
|
@@ -80,42 +83,11 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
|
|
|
80
83
|
|
|
81
84
|
- [对话档](docs/example-conversation.html) —— 只有两轮问答
|
|
82
85
|
- [过程档](docs/example-process.html) —— 多出思考、工具调用、附件;工具结果只剩一行摘要
|
|
83
|
-
- [完整档](docs/example-full.html) ——
|
|
86
|
+
- [完整档](docs/example-full.html) —— 工具结果全文,消息头带模型名
|
|
84
87
|
|
|
85
88
|
> 想直观看出区别,请用**用过工具**的会话(让模型读过文件、跑过命令)。只有纯问答的会话,
|
|
86
89
|
> 大部分开关没有可显示的内容,三档看起来会几乎一样 —— 这是正确的,不是开关失灵。
|
|
87
90
|
|
|
88
|
-
### 轮次头与折叠
|
|
89
|
-
|
|
90
|
-
每轮的助手输出与 DSH 原会话结构一致:
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
已完成,用时 9分52秒 ⌄ ← 轮次头,默认展开
|
|
94
|
-
明白了:<details> 的容器边界搞错了… ← 正文,直接可见
|
|
95
|
-
▸ 调用 2 次工具 bash ← 工具调用,默认收起
|
|
96
|
-
根因找到了… ← 继续的正文,直接可见
|
|
97
|
-
▸ 调用 1 次工具 read
|
|
98
|
-
……
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
两层折叠,各管各的:
|
|
102
|
-
|
|
103
|
-
| 折叠项 | 默认 | 展开后 |
|
|
104
|
-
|---|---|---|
|
|
105
|
-
| **轮次头**(已完成,用时 X) | 展开 | 该轮的全部内容 |
|
|
106
|
-
| **调用 N 次工具** | 收起 | 每次调用的参数与结果 |
|
|
107
|
-
|
|
108
|
-
两条硬规则,都来自 DSH 的做法:
|
|
109
|
-
|
|
110
|
-
1. **助手回复永远不被折叠**。折叠的是过程,回复必须直接可见 ——
|
|
111
|
-
DSH 文档对它的几种展示模式都是这个约定("fold … while keeping every Assistant reply visible")。
|
|
112
|
-
收起轮次头是读者主动选择跳过这一轮,不是我们偷偷把回答藏起来。
|
|
113
|
-
2. **过程里不再套第三层**。同一段连续的工具调用聚合成一个「调用 N 次工具」,
|
|
114
|
-
展开就是参数和结果;不会出现「轮次 → 过程 → 工具」要点三次才看到一行输出。
|
|
115
|
-
|
|
116
|
-
- 状态来自 `turn/end` 的 `reason.kind`(已完成 / 已中止 / 失败 / 已取消)
|
|
117
|
-
- 耗时是该轮从开始到结束的实际时长;没有 `turn/end` 的会话不显示轮次头
|
|
118
|
-
|
|
119
91
|
### 选择轮次
|
|
120
92
|
|
|
121
93
|
会话很长时,可以只导出其中几轮。展开「导出轮次」后按轮勾选:
|
package/lib/index.js
CHANGED
|
@@ -30,11 +30,26 @@ export const CHANNEL = '/api'
|
|
|
30
30
|
export const ENDPOINT_PREFIX = 'share-html/'
|
|
31
31
|
|
|
32
32
|
export function apply(ctx) {
|
|
33
|
-
const handlers = createHandlers(ctx)
|
|
34
|
-
|
|
35
33
|
const logger = typeof ctx.get === "function" ? ctx.get("logger") : undefined
|
|
36
34
|
const log = logger && typeof logger.info === "function" ? logger.info.bind(logger) : console.log
|
|
37
35
|
|
|
36
|
+
// workspaceChanges 是**可选**服务:不是每个 profile 都装了文件变更记录插件,
|
|
37
|
+
// 所以不能用 inject 声明(声明了就会在没有它的环境里永远 PENDING)。
|
|
38
|
+
// 用 ctx.get 安全取:取不到时内核就把「文件改动摘要」整块跳过。
|
|
39
|
+
// 另外它也只在会话仍被本 Host 持有、进程没重启时才有数据。
|
|
40
|
+
let workspaceChanges
|
|
41
|
+
try {
|
|
42
|
+
workspaceChanges = typeof ctx.get === "function" ? ctx.get("workspaceChanges") : undefined
|
|
43
|
+
} catch {
|
|
44
|
+
workspaceChanges = undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const handlers = createHandlers({
|
|
48
|
+
sessionQuery: ctx.sessionQuery,
|
|
49
|
+
...(workspaceChanges ? { workspaceChanges } : {}),
|
|
50
|
+
...(logger ? { logger } : {}),
|
|
51
|
+
})
|
|
52
|
+
|
|
38
53
|
const jsonReply = (body) => new Response(JSON.stringify(body), {
|
|
39
54
|
status: 200,
|
|
40
55
|
headers: { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" },
|
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,25 +133,30 @@ 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;
|
|
156
140
|
}
|
|
141
|
+
// ---- 本轮文件改动摘要 -----------------------------------------------
|
|
142
|
+
// 事件本身只有 {turn},明细靠 options.changes 从 Host 取回。
|
|
143
|
+
// 挂到本轮最后一条 assistant 消息上,渲染在轮末(与 DSH 的位置一致)。
|
|
144
|
+
case "workspace/changes": {
|
|
145
|
+
const changes = options.changes?.get(raw.seq ?? -1);
|
|
146
|
+
if (!changes || !changes.files.length) break;
|
|
147
|
+
const turnNo = asNumber(data.turn);
|
|
148
|
+
const turn = turnNo !== void 0 ? turns.find((t) => t.index === turnNo) ?? current : current;
|
|
149
|
+
if (!turn) break;
|
|
150
|
+
const last = turn.assistants[turn.assistants.length - 1];
|
|
151
|
+
if (last) {
|
|
152
|
+
last.blocks.push(changes);
|
|
153
|
+
} else {
|
|
154
|
+
const host = { id: `changes-${turn.index}`, role: "assistant", blocks: [changes] };
|
|
155
|
+
if (at !== void 0) host.at = at;
|
|
156
|
+
turn.assistants.push(host);
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
157
160
|
case "step/end":
|
|
158
161
|
break;
|
|
159
162
|
default: {
|
|
@@ -187,18 +190,28 @@ function projectUserMessage(msg, at, dropped) {
|
|
|
187
190
|
}
|
|
188
191
|
case "image": {
|
|
189
192
|
dropped.attachmentBytes += 1;
|
|
190
|
-
|
|
193
|
+
const a = asRecord(p.attachment);
|
|
194
|
+
const meta = {
|
|
195
|
+
name: asString(a?.name) ?? asString(p.name) ?? "image",
|
|
196
|
+
type: "IMG"
|
|
197
|
+
};
|
|
198
|
+
const bytes = asNumber(a?.bytes) ?? asNumber(p.bytes) ?? asNumber(p.size);
|
|
199
|
+
if (bytes !== void 0) meta.bytes = bytes;
|
|
200
|
+
files.push(meta);
|
|
191
201
|
break;
|
|
192
202
|
}
|
|
193
203
|
case "file":
|
|
194
204
|
case "attachment": {
|
|
195
|
-
const
|
|
205
|
+
const a = asRecord(p.attachment);
|
|
206
|
+
const name = asString(a?.name) ?? asString(p.name) ?? asString(p.filename);
|
|
196
207
|
if (!name) {
|
|
197
208
|
dropped.attachmentBytes += 1;
|
|
198
209
|
break;
|
|
199
210
|
}
|
|
200
211
|
const meta = { name, type: fileType(name) };
|
|
201
|
-
const
|
|
212
|
+
const mediaType = asString(a?.mediaType);
|
|
213
|
+
if (mediaType) meta.type = mediaType;
|
|
214
|
+
const bytes = asNumber(a?.bytes) ?? asNumber(p.bytes) ?? asNumber(p.size);
|
|
202
215
|
if (bytes !== void 0) meta.bytes = bytes;
|
|
203
216
|
files.push(meta);
|
|
204
217
|
break;
|
|
@@ -240,6 +253,20 @@ function collectAssistantBlocks(msg, target, dropped) {
|
|
|
240
253
|
dropped.attachmentBytes += 1;
|
|
241
254
|
break;
|
|
242
255
|
}
|
|
256
|
+
case "file":
|
|
257
|
+
case "attachment": {
|
|
258
|
+
const a = asRecord(p.attachment);
|
|
259
|
+
const name = asString(a?.name) ?? asString(p.name) ?? asString(p.filename);
|
|
260
|
+
if (!name) {
|
|
261
|
+
dropped.attachmentBytes += 1;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
const meta = { name, type: asString(a?.mediaType) ?? fileType(name) };
|
|
265
|
+
const bytes = asNumber(a?.bytes) ?? asNumber(p.bytes) ?? asNumber(p.size);
|
|
266
|
+
if (bytes !== void 0) meta.bytes = bytes;
|
|
267
|
+
target.blocks.push({ kind: "files", files: [meta] });
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
243
270
|
case "tool-call":
|
|
244
271
|
case "tool-call-delta":
|
|
245
272
|
break;
|
|
@@ -499,6 +526,8 @@ function pruneBlock(block, include, stats) {
|
|
|
499
526
|
case "files":
|
|
500
527
|
if (!include.files) return null;
|
|
501
528
|
return { kind: "files", files: block.files };
|
|
529
|
+
case "changes":
|
|
530
|
+
return include.toolCalls ? block : null;
|
|
502
531
|
case "research":
|
|
503
532
|
return include.deepResearch ? block : null;
|
|
504
533
|
case "tool": {
|
|
@@ -684,6 +713,15 @@ function redactBlock(block, options, hits) {
|
|
|
684
713
|
kind: "files",
|
|
685
714
|
files: block.files.map((f) => ({ ...f, name: redactText(f.name, options, hits) }))
|
|
686
715
|
};
|
|
716
|
+
case "changes":
|
|
717
|
+
return {
|
|
718
|
+
...block,
|
|
719
|
+
files: block.files.map((f) => ({
|
|
720
|
+
...f,
|
|
721
|
+
path: redactText(f.path, options, hits),
|
|
722
|
+
display: redactText(f.display, options, hits)
|
|
723
|
+
}))
|
|
724
|
+
};
|
|
687
725
|
case "tool": {
|
|
688
726
|
const out = { ...block };
|
|
689
727
|
if (block.args !== void 0) out.args = redactText(block.args, options, hits);
|
|
@@ -1648,181 +1686,118 @@ main { display: flex; flex-direction: column; gap: 28px; }
|
|
|
1648
1686
|
|
|
1649
1687
|
.file-meta { color: var(--dsh-label-tertiary); font-size: 12px; line-height: 15px; }
|
|
1650
1688
|
|
|
1651
|
-
/* ---------- \
|
|
1689
|
+
/* ---------- \u672C\u8F6E\u6587\u4EF6\u6539\u52A8\u6458\u8981\uFF08\u5BF9\u5E94 DSH \u7684\u300C\u5DF2\u7F16\u8F91 N \u4E2A\u6587\u4EF6\u300D\uFF09 ---------- */
|
|
1652
1690
|
|
|
1653
|
-
details.
|
|
1654
|
-
margin:
|
|
1655
|
-
border
|
|
1691
|
+
details.changes {
|
|
1692
|
+
margin: 8px 0 2px;
|
|
1693
|
+
border: .5px solid var(--dsh-border-l2);
|
|
1694
|
+
border-radius: var(--dsh-radius-lg);
|
|
1695
|
+
background: var(--dsh-input-major);
|
|
1696
|
+
overflow: hidden;
|
|
1656
1697
|
}
|
|
1657
1698
|
|
|
1658
|
-
details.
|
|
1699
|
+
details.changes > summary {
|
|
1659
1700
|
display: flex;
|
|
1660
1701
|
align-items: center;
|
|
1661
1702
|
gap: 8px;
|
|
1662
|
-
min-height:
|
|
1663
|
-
padding:
|
|
1703
|
+
min-height: 40px;
|
|
1704
|
+
padding: 8px 14px;
|
|
1664
1705
|
cursor: pointer;
|
|
1665
|
-
|
|
1706
|
+
list-style: none;
|
|
1707
|
+
color: var(--dsh-label-primary);
|
|
1666
1708
|
font-size: 13px;
|
|
1667
1709
|
line-height: 20px;
|
|
1668
|
-
list-style: none;
|
|
1669
|
-
user-select: none;
|
|
1670
1710
|
}
|
|
1671
1711
|
|
|
1672
|
-
details.
|
|
1712
|
+
details.changes > summary::-webkit-details-marker { display: none; }
|
|
1673
1713
|
|
|
1674
|
-
|
|
1714
|
+
/* \u7528\u65CB\u8F6C\u7684\u4E09\u89D2\u66FF\u4EE3\u9ED8\u8BA4\u7BAD\u5934\uFF0C\u4FDD\u6301\u96F6\u811A\u672C\u3001\u7EAF CSS */
|
|
1715
|
+
details.changes > summary::before {
|
|
1675
1716
|
content: "";
|
|
1676
1717
|
flex: none;
|
|
1677
|
-
width:
|
|
1678
|
-
height:
|
|
1679
|
-
|
|
1680
|
-
border-
|
|
1681
|
-
border-bottom:
|
|
1682
|
-
|
|
1683
|
-
transition: transform var(--dsh-duration-fast) var(--dsh-ease-in-out);
|
|
1718
|
+
width: 0;
|
|
1719
|
+
height: 0;
|
|
1720
|
+
border-left: 5px solid var(--dsh-label-tertiary);
|
|
1721
|
+
border-top: 4px solid transparent;
|
|
1722
|
+
border-bottom: 4px solid transparent;
|
|
1723
|
+
transition: transform .15s ease;
|
|
1684
1724
|
}
|
|
1685
1725
|
|
|
1686
|
-
details.
|
|
1726
|
+
details.changes[open] > summary::before { transform: rotate(90deg); }
|
|
1687
1727
|
|
|
1688
|
-
|
|
1728
|
+
.chg-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1689
1729
|
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1730
|
+
.chg-added { color: var(--dsh-state-success-primary); font-variant-numeric: tabular-nums; }
|
|
1731
|
+
.chg-deleted { color: var(--dsh-state-error-primary); font-variant-numeric: tabular-nums; }
|
|
1732
|
+
|
|
1733
|
+
details.changes > summary .chg-added,
|
|
1734
|
+
details.changes > summary .chg-deleted { flex: none; font-size: 12px; }
|
|
1735
|
+
|
|
1736
|
+
.chg-body { border-top: .5px solid var(--dsh-border-l2); padding: 6px 0; }
|
|
1694
1737
|
|
|
1695
|
-
|
|
1738
|
+
.chg-list { margin: 0; padding: 0; list-style: none; }
|
|
1739
|
+
|
|
1740
|
+
.chg-row {
|
|
1696
1741
|
display: flex;
|
|
1697
1742
|
align-items: center;
|
|
1698
|
-
gap:
|
|
1699
|
-
|
|
1700
|
-
padding: 2px 0;
|
|
1701
|
-
cursor: pointer;
|
|
1702
|
-
list-style: none;
|
|
1703
|
-
color: var(--dsh-label-tertiary);
|
|
1743
|
+
gap: 12px;
|
|
1744
|
+
padding: 3px 14px;
|
|
1704
1745
|
font-size: 12px;
|
|
1705
|
-
line-height:
|
|
1746
|
+
line-height: 20px;
|
|
1706
1747
|
}
|
|
1707
1748
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
border-bottom: 1.5px solid currentColor;
|
|
1717
|
-
transform: rotate(-45deg);
|
|
1718
|
-
transition: transform var(--dsh-duration-fast) var(--dsh-ease-in-out);
|
|
1749
|
+
.chg-path {
|
|
1750
|
+
flex: 1 1 auto;
|
|
1751
|
+
min-width: 0;
|
|
1752
|
+
overflow: hidden;
|
|
1753
|
+
text-overflow: ellipsis;
|
|
1754
|
+
white-space: nowrap;
|
|
1755
|
+
color: var(--dsh-label-secondary);
|
|
1756
|
+
font-family: var(--dsh-font-code);
|
|
1719
1757
|
}
|
|
1720
1758
|
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
.turn-head .turn-meta { font-variant-numeric: tabular-nums; }
|
|
1724
|
-
.turn-head .msg-model { color: var(--dsh-label-caption); }
|
|
1759
|
+
.chg-stat { flex: none; display: inline-flex; gap: 8px; font-variant-numeric: tabular-nums; }
|
|
1725
1760
|
|
|
1726
|
-
|
|
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
|
-
}
|
|
1761
|
+
.chg-note { color: var(--dsh-label-tertiary); }
|
|
1735
1762
|
|
|
1736
|
-
|
|
1737
|
-
.turn-body { margin: 2px 0 0; }
|
|
1738
|
-
.turn-body > *:first-child { margin-top: 0; }
|
|
1763
|
+
.chg-more { color: var(--dsh-label-tertiary); font-style: italic; }
|
|
1739
1764
|
|
|
1740
|
-
/* ---------- \
|
|
1765
|
+
/* ---------- \u6298\u53E0\u5757\uFF08\u601D\u8003 / \u5DE5\u5177 / \u68C0\u7D22 / \u6DF1\u7814\uFF09 ---------- */
|
|
1741
1766
|
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
margin: 6px 0;
|
|
1767
|
+
details.process {
|
|
1768
|
+
margin: 2px 0;
|
|
1745
1769
|
border-radius: var(--dsh-radius-sm);
|
|
1746
1770
|
}
|
|
1747
1771
|
|
|
1748
|
-
details.
|
|
1772
|
+
details.process > summary {
|
|
1749
1773
|
display: flex;
|
|
1750
1774
|
align-items: center;
|
|
1751
1775
|
gap: 8px;
|
|
1752
|
-
min-height:
|
|
1776
|
+
min-height: 28px;
|
|
1753
1777
|
padding: 2px 0;
|
|
1754
1778
|
cursor: pointer;
|
|
1755
|
-
list-style: none;
|
|
1756
|
-
font-size: 12px;
|
|
1757
|
-
line-height: 18px;
|
|
1758
1779
|
color: var(--dsh-label-tertiary);
|
|
1780
|
+
font-size: 13px;
|
|
1781
|
+
line-height: 20px;
|
|
1782
|
+
list-style: none;
|
|
1783
|
+
user-select: none;
|
|
1759
1784
|
}
|
|
1760
1785
|
|
|
1761
|
-
details.
|
|
1786
|
+
details.process > summary::-webkit-details-marker { display: none; }
|
|
1762
1787
|
|
|
1763
|
-
details.
|
|
1788
|
+
details.process > summary::after {
|
|
1764
1789
|
content: "";
|
|
1765
1790
|
flex: none;
|
|
1766
1791
|
width: 6px;
|
|
1767
1792
|
height: 6px;
|
|
1793
|
+
margin-right: 2px;
|
|
1768
1794
|
border-right: 1.5px solid currentColor;
|
|
1769
1795
|
border-bottom: 1.5px solid currentColor;
|
|
1770
1796
|
transform: rotate(-45deg);
|
|
1771
1797
|
transition: transform var(--dsh-duration-fast) var(--dsh-ease-in-out);
|
|
1772
1798
|
}
|
|
1773
1799
|
|
|
1774
|
-
details.
|
|
1775
|
-
|
|
1776
|
-
details.tool-group > summary:focus-visible {
|
|
1777
|
-
outline: 1.5px solid var(--dsh-link);
|
|
1778
|
-
outline-offset: 2px;
|
|
1779
|
-
border-radius: var(--dsh-radius-sm);
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
@media (hover: hover) {
|
|
1783
|
-
details.tool-group > summary:hover { color: var(--dsh-label-secondary); }
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
.tool-group .sum-names {
|
|
1787
|
-
color: var(--dsh-label-caption);
|
|
1788
|
-
font-family: var(--dsh-font-code);
|
|
1789
|
-
font-size: 11px;
|
|
1790
|
-
}
|
|
1791
|
-
|
|
1792
|
-
.tool-group-body {
|
|
1793
|
-
margin: 2px 0 4px 14px;
|
|
1794
|
-
padding-left: 10px;
|
|
1795
|
-
border-left: 1px solid var(--dsh-border-l2);
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
/* ---------- \u5DE5\u5177\u8C03\u7528\u7684\u6241\u5E73\u5185\u5BB9 ---------- */
|
|
1799
|
-
/* \u5DF2\u7ECF\u5728\u300C\u8C03\u7528 N \u6B21\u5DE5\u5177\u300D\u91CC\u4E86\uFF0C\u5C31\u4E0D\u518D\u5957\u7B2C\u4E8C\u5C42 <details>\uFF1A
|
|
1800
|
-
\u5426\u5219\u8BFB\u4E00\u884C\u8F93\u51FA\u8981\u70B9\u4E24\u6B21\uFF08\u8F6E\u6B21 \u2192 \u5DE5\u5177\u7EC4 \u2192 \u5DE5\u5177\uFF09\u3002 */
|
|
1801
|
-
.flat-block {
|
|
1802
|
-
margin: 6px 0;
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
.flat-head {
|
|
1806
|
-
display: flex;
|
|
1807
|
-
align-items: center;
|
|
1808
|
-
gap: 8px;
|
|
1809
|
-
font-size: 12px;
|
|
1810
|
-
line-height: 18px;
|
|
1811
|
-
color: var(--dsh-label-tertiary);
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
.flat-head .sum-name {
|
|
1815
|
-
color: var(--dsh-label-secondary);
|
|
1816
|
-
font-family: var(--dsh-font-code);
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
.flat-body {
|
|
1820
|
-
margin: 2px 0 0;
|
|
1821
|
-
overflow-wrap: anywhere;
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
.flat-body > *:first-child { margin-top: 0; }
|
|
1825
|
-
.flat-body > *:last-child { margin-bottom: 0; }
|
|
1800
|
+
details.process[open] > summary::after { transform: rotate(45deg); }
|
|
1826
1801
|
|
|
1827
1802
|
@media (hover: hover) {
|
|
1828
1803
|
details.process > summary:hover { color: var(--dsh-label-secondary); }
|
|
@@ -2167,17 +2142,20 @@ function renderHtml(model, meta = {}) {
|
|
|
2167
2142
|
stats.messages += 1;
|
|
2168
2143
|
body.push(renderUserMessage(turn.user));
|
|
2169
2144
|
}
|
|
2170
|
-
const
|
|
2145
|
+
const assistantBlocks = [];
|
|
2171
2146
|
const turnModels = [];
|
|
2172
2147
|
for (const msg of turn.assistants) {
|
|
2173
2148
|
stats.messages += 1;
|
|
2174
2149
|
stats.toolCalls += msg.blocks.filter((b) => b.kind === "tool").length;
|
|
2175
2150
|
if (msg.model && !turnModels.includes(msg.model)) turnModels.push(msg.model);
|
|
2176
|
-
|
|
2177
|
-
if (rendered.trim()) turnBlocks.push(rendered);
|
|
2151
|
+
assistantBlocks.push(renderAssistantMessage(msg));
|
|
2178
2152
|
}
|
|
2179
|
-
if (
|
|
2180
|
-
|
|
2153
|
+
if (assistantBlocks.length) {
|
|
2154
|
+
const head = turnModels.length ? `<header class="msg-head"><span class="msg-model">${turnModels.map(esc).join(" \xB7 ")}</span></header>
|
|
2155
|
+
` : "";
|
|
2156
|
+
body.push(`<article class="msg" data-role="assistant">
|
|
2157
|
+
${head}${assistantBlocks.join("\n")}
|
|
2158
|
+
</article>`);
|
|
2181
2159
|
}
|
|
2182
2160
|
}
|
|
2183
2161
|
if (!body.length) {
|
|
@@ -2282,60 +2260,13 @@ function renderUserMessage(msg) {
|
|
|
2282
2260
|
${parts.join("\n")}
|
|
2283
2261
|
</article>`;
|
|
2284
2262
|
}
|
|
2285
|
-
function renderTurnArticle(turn, blocks, models) {
|
|
2286
|
-
const status = statusLabel(turn.status);
|
|
2287
|
-
const duration = turn.durationMs !== void 0 ? formatDuration(turn.durationMs) : "";
|
|
2288
|
-
const metaParts = [status, duration ? `\u7528\u65F6 ${duration}` : ""].filter(Boolean);
|
|
2289
|
-
const metaHtml = metaParts.length ? `<span class="turn-meta">${esc(metaParts.join("\uFF0C"))}</span>` : "";
|
|
2290
|
-
const modelHtml = models.length ? `<span class="msg-model">${models.map(esc).join(" \xB7 ")}</span>` : "";
|
|
2291
|
-
const inner = blocks.join("\n");
|
|
2292
|
-
if (!metaHtml && !modelHtml) {
|
|
2293
|
-
return `<article class="msg" data-role="assistant">
|
|
2294
|
-
${inner}
|
|
2295
|
-
</article>`;
|
|
2296
|
-
}
|
|
2297
|
-
return `<article class="msg" data-role="assistant">
|
|
2298
|
-
<details class="turn" open>
|
|
2299
|
-
<summary class="turn-head">${metaHtml}${modelHtml}</summary>
|
|
2300
|
-
<div class="turn-body">
|
|
2301
|
-
${inner}
|
|
2302
|
-
</div>
|
|
2303
|
-
</details>
|
|
2304
|
-
</article>`;
|
|
2305
|
-
}
|
|
2306
2263
|
function renderAssistantMessage(msg) {
|
|
2307
2264
|
const parts = [];
|
|
2308
|
-
let pendingTools = [];
|
|
2309
|
-
const flushTools = () => {
|
|
2310
|
-
if (!pendingTools.length) return;
|
|
2311
|
-
parts.push(renderToolGroup(pendingTools));
|
|
2312
|
-
pendingTools = [];
|
|
2313
|
-
};
|
|
2314
2265
|
for (const block of msg.blocks) {
|
|
2315
|
-
if (block.kind === "tool") {
|
|
2316
|
-
pendingTools.push(block);
|
|
2317
|
-
continue;
|
|
2318
|
-
}
|
|
2319
|
-
flushTools();
|
|
2320
2266
|
parts.push(renderBlock(block));
|
|
2321
2267
|
}
|
|
2322
|
-
flushTools();
|
|
2323
2268
|
return parts.filter(Boolean).join("\n");
|
|
2324
2269
|
}
|
|
2325
|
-
function renderToolGroup(tools) {
|
|
2326
|
-
const n = tools.length;
|
|
2327
|
-
const failed = tools.filter((t) => t.status === "error").length;
|
|
2328
|
-
const label = n === 1 ? "\u8C03\u7528 1 \u6B21\u5DE5\u5177" : `\u8C03\u7528 ${n} \u6B21\u5DE5\u5177`;
|
|
2329
|
-
const names = [...new Set(tools.map((t) => t.name))].join(", ");
|
|
2330
|
-
const failBadge = failed ? `<span class="sum-state" data-status="error">${failed} \u4E2A\u5931\u8D25</span>` : "";
|
|
2331
|
-
const body = tools.map((t) => renderTool(t, true)).join("\n");
|
|
2332
|
-
return `<details class="tool-group" data-kind="tool-group">
|
|
2333
|
-
<summary><span class="sum-text">${esc(label)}</span><span class="sum-names">${esc(names)}</span>${failBadge}</summary>
|
|
2334
|
-
<div class="tool-group-body">
|
|
2335
|
-
${body}
|
|
2336
|
-
</div>
|
|
2337
|
-
</details>`;
|
|
2338
|
-
}
|
|
2339
2270
|
function renderBlock(block) {
|
|
2340
2271
|
switch (block.kind) {
|
|
2341
2272
|
case "text":
|
|
@@ -2360,13 +2291,14 @@ function renderBlock(block) {
|
|
|
2360
2291
|
});
|
|
2361
2292
|
case "files":
|
|
2362
2293
|
return renderFiles(block.files);
|
|
2294
|
+
case "changes":
|
|
2295
|
+
return renderChanges(block);
|
|
2363
2296
|
}
|
|
2364
2297
|
}
|
|
2365
2298
|
function renderDetails(input) {
|
|
2366
2299
|
const statusAttr = input.status ? ` data-status="${esc(input.status)}"` : "";
|
|
2367
2300
|
const nameHtml = input.name ? `<span class="sum-name">${esc(input.name)}</span>` : "";
|
|
2368
|
-
|
|
2369
|
-
return `<details class="process" data-kind="${esc(input.kind)}"${openAttr}>
|
|
2301
|
+
return `<details class="process" data-kind="${esc(input.kind)}">
|
|
2370
2302
|
<summary><span class="sum-text">${esc(input.summary)}</span>${nameHtml}${statusDot(input.status)}</summary>
|
|
2371
2303
|
<div class="process-body">
|
|
2372
2304
|
${input.body}
|
|
@@ -2401,13 +2333,12 @@ function renderTool(block) {
|
|
|
2401
2333
|
body.push('<div class="trunc-note">\u4F1A\u8BDD\u5BFC\u51FA\u65F6\u8BE5\u8C03\u7528\u5C1A\u672A\u8FD4\u56DE</div>');
|
|
2402
2334
|
}
|
|
2403
2335
|
const stateText = block.status === "error" ? "\u5931\u8D25" : block.status === "pending" ? "\u672A\u5B8C\u6210" : "";
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
<div class="
|
|
2407
|
-
<div class="flat-body">
|
|
2336
|
+
return `<details class="process" data-kind="tool" data-tool="${esc(block.name)}">
|
|
2337
|
+
<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>
|
|
2338
|
+
<div class="process-body">
|
|
2408
2339
|
${body.join("\n")}
|
|
2409
2340
|
</div>
|
|
2410
|
-
</
|
|
2341
|
+
</details>`;
|
|
2411
2342
|
}
|
|
2412
2343
|
function toolSummary(block) {
|
|
2413
2344
|
const fields = block.argsFields ?? [];
|
|
@@ -2451,6 +2382,25 @@ function renderFiles(files) {
|
|
|
2451
2382
|
}).join("");
|
|
2452
2383
|
return `<div class="files">${cards}</div>`;
|
|
2453
2384
|
}
|
|
2385
|
+
function renderChanges(block) {
|
|
2386
|
+
const counts = `<span class="chg-added">+${block.added}</span><span class="chg-deleted">-${block.deleted}</span>`;
|
|
2387
|
+
const single = block.total === 1 ? block.files[0] : void 0;
|
|
2388
|
+
const title = single ? `\u5DF2\u7F16\u8F91 ${basename(single.display)}` : `\u5DF2\u7F16\u8F91 ${block.total} \u4E2A\u6587\u4EF6`;
|
|
2389
|
+
const rows = block.files.map((f) => {
|
|
2390
|
+
const stat = f.binary === true ? '<span class="chg-note">\u4E8C\u8FDB\u5236</span>' : f.oversized === true ? '<span class="chg-note">\u8FC7\u5927</span>' : `<span class="chg-added">+${f.added}</span><span class="chg-deleted">-${f.deleted}</span>`;
|
|
2391
|
+
return `<li class="chg-row"><span class="chg-path">${esc(f.display)}</span><span class="chg-stat">${stat}</span></li>`;
|
|
2392
|
+
}).join("\n");
|
|
2393
|
+
const more = block.total > block.files.length ? `<li class="chg-row chg-more">\u53E6\u6709 ${block.total - block.files.length} \u4E2A\u6587\u4EF6\u672A\u5217\u51FA</li>` : "";
|
|
2394
|
+
return `<details class="changes">
|
|
2395
|
+
<summary><span class="chg-title">${esc(title)}</span>${counts}</summary>
|
|
2396
|
+
<div class="chg-body">
|
|
2397
|
+
<ul class="chg-list">
|
|
2398
|
+
${rows}
|
|
2399
|
+
${more}
|
|
2400
|
+
</ul>
|
|
2401
|
+
</div>
|
|
2402
|
+
</details>`;
|
|
2403
|
+
}
|
|
2454
2404
|
function basename(name) {
|
|
2455
2405
|
const parts = name.split(/[\\/]/).filter(Boolean);
|
|
2456
2406
|
return parts.length ? parts[parts.length - 1] ?? name : name;
|
|
@@ -2467,33 +2417,6 @@ function formatBytes(bytes) {
|
|
|
2467
2417
|
}
|
|
2468
2418
|
return `${value >= 10 ? Math.round(value) : value.toFixed(1)} ${units[unit]}`;
|
|
2469
2419
|
}
|
|
2470
|
-
function formatDuration(ms) {
|
|
2471
|
-
if (!Number.isFinite(ms) || ms < 0) return "";
|
|
2472
|
-
const totalSeconds = Math.floor(ms / 1e3);
|
|
2473
|
-
if (totalSeconds < 1) return "\u4E0D\u8DB31\u79D2";
|
|
2474
|
-
const hours = Math.floor(totalSeconds / 3600);
|
|
2475
|
-
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
2476
|
-
const seconds = totalSeconds % 60;
|
|
2477
|
-
if (hours > 0) return `${hours}\u5C0F\u65F6${minutes}\u5206${seconds}\u79D2`;
|
|
2478
|
-
if (minutes > 0) return `${minutes}\u5206${seconds}\u79D2`;
|
|
2479
|
-
return `${seconds}\u79D2`;
|
|
2480
|
-
}
|
|
2481
|
-
function statusLabel(status) {
|
|
2482
|
-
switch (status) {
|
|
2483
|
-
case "completed":
|
|
2484
|
-
return "\u5DF2\u5B8C\u6210";
|
|
2485
|
-
case "aborted":
|
|
2486
|
-
return "\u5DF2\u4E2D\u6B62";
|
|
2487
|
-
case "failed":
|
|
2488
|
-
return "\u5931\u8D25";
|
|
2489
|
-
case "cancelled":
|
|
2490
|
-
return "\u5DF2\u53D6\u6D88";
|
|
2491
|
-
case void 0:
|
|
2492
|
-
return "";
|
|
2493
|
-
default:
|
|
2494
|
-
return status;
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
2420
|
function presetLabel(preset) {
|
|
2498
2421
|
switch (preset) {
|
|
2499
2422
|
case "conversation":
|
|
@@ -2564,7 +2487,7 @@ function filenameStamp(epochMs, timeZone) {
|
|
|
2564
2487
|
}
|
|
2565
2488
|
|
|
2566
2489
|
// src/host/index.ts
|
|
2567
|
-
var VERSION = "0.
|
|
2490
|
+
var VERSION = "0.5.1";
|
|
2568
2491
|
function exportSession(input) {
|
|
2569
2492
|
const preset = input.preset ?? "conversation";
|
|
2570
2493
|
const opts = shareOptions(preset, input.options ?? {});
|
|
@@ -2758,6 +2681,7 @@ async function renderForRequest(ctx, rawRequest, options = {}) {
|
|
|
2758
2681
|
if (truncatedEvents.length < events.length) {
|
|
2759
2682
|
warnings.push(`\u4F1A\u8BDD\u4E8B\u4EF6\u8FC7\u591A\uFF0C\u4EC5\u5BFC\u51FA\u524D ${MAX_EVENTS} \u6761\uFF08\u5171 ${events.length} \u6761\uFF09`);
|
|
2760
2683
|
}
|
|
2684
|
+
const changes = collectChanges(ctx, request.sessionId, truncatedEvents);
|
|
2761
2685
|
const shareOptions2 = {};
|
|
2762
2686
|
if (request.turns !== void 0) shareOptions2.turns = request.turns;
|
|
2763
2687
|
if (request.include) shareOptions2.include = { ...presetInclude(request.preset), ...request.include };
|
|
@@ -2773,7 +2697,8 @@ async function renderForRequest(ctx, rawRequest, options = {}) {
|
|
|
2773
2697
|
},
|
|
2774
2698
|
projectOptions: {
|
|
2775
2699
|
sessionId: request.sessionId,
|
|
2776
|
-
...title ? { title } : {}
|
|
2700
|
+
...title ? { title } : {},
|
|
2701
|
+
...changes.size ? { changes } : {}
|
|
2777
2702
|
},
|
|
2778
2703
|
meta: { timeZone },
|
|
2779
2704
|
exportedAt: now()
|
|
@@ -2878,6 +2803,39 @@ function toRawEvents(snapshot) {
|
|
|
2878
2803
|
}
|
|
2879
2804
|
return out;
|
|
2880
2805
|
}
|
|
2806
|
+
function collectChanges(ctx, sessionId, events) {
|
|
2807
|
+
const out = /* @__PURE__ */ new Map();
|
|
2808
|
+
const service = ctx.workspaceChanges;
|
|
2809
|
+
if (!service) return out;
|
|
2810
|
+
for (const event of events) {
|
|
2811
|
+
if (event.type !== "workspace/changes") continue;
|
|
2812
|
+
const seq = event.seq;
|
|
2813
|
+
if (typeof seq !== "number") continue;
|
|
2814
|
+
let summary;
|
|
2815
|
+
try {
|
|
2816
|
+
summary = service.summary(sessionId, seq);
|
|
2817
|
+
} catch (error) {
|
|
2818
|
+
ctx.logger?.warn("[dsh-share-html] \u8BFB\u53D6\u6587\u4EF6\u6539\u52A8\u6458\u8981\u5931\u8D25\uFF08seq=%s\uFF09\uFF1A%s", seq, String(error));
|
|
2819
|
+
continue;
|
|
2820
|
+
}
|
|
2821
|
+
if (!summary || !Array.isArray(summary.files)) continue;
|
|
2822
|
+
out.set(seq, {
|
|
2823
|
+
kind: "changes",
|
|
2824
|
+
files: summary.files.map((f) => ({
|
|
2825
|
+
path: f.path,
|
|
2826
|
+
display: f.display,
|
|
2827
|
+
added: f.added,
|
|
2828
|
+
deleted: f.deleted,
|
|
2829
|
+
...f.binary === true ? { binary: true } : {},
|
|
2830
|
+
...f.oversized === true ? { oversized: true } : {}
|
|
2831
|
+
})),
|
|
2832
|
+
total: summary.total,
|
|
2833
|
+
added: summary.added,
|
|
2834
|
+
deleted: summary.deleted
|
|
2835
|
+
});
|
|
2836
|
+
}
|
|
2837
|
+
return out;
|
|
2838
|
+
}
|
|
2881
2839
|
function defaultTimeZone() {
|
|
2882
2840
|
try {
|
|
2883
2841
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
@@ -2906,6 +2864,7 @@ export {
|
|
|
2906
2864
|
MAX_EVENTS,
|
|
2907
2865
|
MAX_HTML_BYTES,
|
|
2908
2866
|
capabilitiesForRequest,
|
|
2867
|
+
collectChanges,
|
|
2909
2868
|
createHandlers,
|
|
2910
2869
|
renderForRequest,
|
|
2911
2870
|
toRawEvents,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-share-html",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
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",
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
"snapshot:tokens": "node scripts/snapshot-tokens.mjs",
|
|
12
12
|
"fixture": "node --experimental-strip-types scripts/replay.ts",
|
|
13
13
|
"build": "node scripts/build.mjs",
|
|
14
|
+
"dev": "node scripts/watch.mjs",
|
|
15
|
+
"dev:fast": "node scripts/watch.mjs --no-test",
|
|
14
16
|
"prepublishOnly": "npm run build && npm test"
|
|
15
17
|
},
|
|
16
18
|
"files": [
|