dsh-share-html 0.3.0 → 0.4.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 CHANGED
@@ -52,7 +52,7 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
52
52
  | **过程** | 再加思考、工具调用、检索结果 | 展示推理过程 |
53
53
  | **完整** | 再加工具结果全文、附件、模型信息 | 完整存档、复盘 |
54
54
 
55
- 三档严格递增。档位只是起点 —— 下面的开关(思考过程 / 检索结果 / 工具调用 / 工具结果 / 附件 / 深度研究 / 模型信息)每一项都能单独开关。
55
+ 三档严格递增。档位只是起点 —— 下面的开关(思考过程 / 工具调用 / 工具结果 / 附件 / 模型信息)每一项都能单独开关。
56
56
 
57
57
  **手动改过任一开关后,档位会标为「自定义」**,并且不再高亮任何一档,这样就不会出现「明明改了,顶上还显示对话」的错觉。再点任一档位即恢复该档默认。
58
58
 
@@ -61,17 +61,16 @@ dsh plugin --profile web add github:unknown3310v0/dsh-share-html
61
61
  | 开关 | 关闭时 | 打开时 |
62
62
  |---|---|---|
63
63
  | **思考过程** | 完全看不到模型推理 | 折叠的「思考过程」块,点开可见推理原文 |
64
- | **检索结果** | 看不到搜索来源 | 列出检索命中的条目与链接 ⚠️ |
65
64
  | **工具调用** | 整段工具交互消失 | 折叠的「工具名 + 参数摘要」 |
66
65
  | **工具结果** | 只留一行摘要(`共 3 行 / 52 字符`) | 结果正文全文 |
67
66
  | **附件** | 不显示文件条目 | 文件名 + 类型 + 大小(不含内容)|
68
- | **深度研究** | 不显示深研过程 | 折叠的深研过程块 ⚠️ |
69
67
  | **模型信息** | 轮次头只显示状态与耗时 | 轮次头多一个模型名 |
70
68
 
71
- > ⚠️ **检索结果 / 深度研究暂时不会产生内容。** 这两个块的渲染与裁剪逻辑都已就位,
72
- > 但 DSH 的事件流里没有对应的结构化事件 —— 检索结果目前就是普通的工具结果,
73
- > 深研过程也没有单独事件(DESIGN 里记为待确认项 O2)。所以在真实会话上,
74
- > 这两个开关拨动不会有可见变化,等 DSH 补上事件形态后接一行投影即可。
69
+ > **关于「检索结果」和「深度研究」**:这两个开关曾经存在,v0.3.1 起已从界面上移除。
70
+ > 它们的渲染与裁剪逻辑都已写好,但 DSH 的事件流里没有对应的结构化事件 ——
71
+ > 检索结果目前表现为普通的工具结果,深研过程也没有独立事件(DESIGN 记为待确认项 O2)。
72
+ > 摆一个拨动后毫无变化的开关,比不摆更让人困惑,所以先收起;
73
+ > 契约层仍然接受这两个字段(老客户端传过来不会报错),等 DSH 补上事件形态后加回界面即可。
75
74
 
76
75
  ### 想看三档的实际差别
77
76
 
package/lib/client.js CHANGED
@@ -305,13 +305,22 @@ window.__ModuleLoader__.load({
305
305
  { value: 'full', label: '完整', hint: '加上工具结果全文、文件与模型信息' },
306
306
  ]
307
307
 
308
+ // 界面上真正露出来的开关。
309
+ //
310
+ // 这里故意不含 retrieval / deepResearch:这两个块的渲染与裁剪都写好了,
311
+ // 但 DSH 的事件流里没有对应事件(检索结果目前就是普通工具结果,深研也没有
312
+ // 独立事件),所以拨动它们永远不会有可见变化。摆一个不生效的开关比不摆更糟。
313
+ // 契约层仍然接受这两个字段(见 contract.ts 的 INCLUDE_KEYS),因此老客户端
314
+ // 传过来不会报错;等 DSH 补上事件形态,把键加回这个对象即可。
315
+ var INCLUDE_ORDER = [
316
+ 'reasoning', 'toolCalls', 'toolResults', 'files', 'modelMeta',
317
+ ]
318
+
308
319
  var INCLUDE_LABELS = {
309
320
  reasoning: { label: '思考过程', hint: '模型的推理内容' },
310
- retrieval: { label: '检索结果', hint: '搜索结果条目' },
311
321
  toolCalls: { label: '工具调用', hint: '工具名与参数' },
312
322
  toolResults: { label: '工具结果', hint: '结果正文(关掉只留一行摘要)' },
313
323
  files: { label: '附件', hint: '只显示文件名与类型,不含内容' },
314
- deepResearch: { label: '深度研究', hint: '深研过程折叠展示' },
315
324
  modelMeta: { label: '模型信息', hint: '模型名与耗时' },
316
325
  }
317
326
 
@@ -648,7 +657,7 @@ window.__ModuleLoader__.load({
648
657
  ]),
649
658
 
650
659
  h('div', { key: 'i', style: { display: 'flex', flexDirection: 'column', gap: 2 } },
651
- Object.keys(INCLUDE_LABELS).map(function (key) {
660
+ INCLUDE_ORDER.map(function (key) {
652
661
  return h(Switch, {
653
662
  key: key,
654
663
  label: INCLUDE_LABELS[key].label,
package/lib/kernel.js CHANGED
@@ -1737,6 +1737,36 @@ details.turn > summary.turn-head:focus-visible {
1737
1737
  .turn-body { margin: 2px 0 0; }
1738
1738
  .turn-body > *:first-child { margin-top: 0; }
1739
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
+
1740
1770
  @media (hover: hover) {
1741
1771
  details.process > summary:hover { color: var(--dsh-label-secondary); }
1742
1772
  }
@@ -2081,15 +2111,20 @@ function renderHtml(model, meta = {}) {
2081
2111
  body.push(renderUserMessage(turn.user));
2082
2112
  }
2083
2113
  const assistantBlocks = [];
2114
+ const stepBlocks = [];
2084
2115
  const turnModels = [];
2085
- for (const msg of turn.assistants) {
2116
+ const lastIndex = turn.assistants.length - 1;
2117
+ for (const [i, msg] of turn.assistants.entries()) {
2086
2118
  stats.messages += 1;
2087
2119
  stats.toolCalls += msg.blocks.filter((b) => b.kind === "tool").length;
2088
2120
  if (msg.model && !turnModels.includes(msg.model)) turnModels.push(msg.model);
2089
- assistantBlocks.push(renderAssistantMessage(msg));
2121
+ const rendered = renderAssistantMessage(msg, i !== lastIndex);
2122
+ if (!rendered) continue;
2123
+ if (i === lastIndex) assistantBlocks.push(rendered);
2124
+ else if (rendered.trim()) stepBlocks.push(rendered);
2090
2125
  }
2091
- if (assistantBlocks.length) {
2092
- body.push(renderTurnArticle(turn, assistantBlocks, turnModels));
2126
+ if (assistantBlocks.length || stepBlocks.length) {
2127
+ body.push(renderTurnArticle(turn, stepBlocks, assistantBlocks, turnModels));
2093
2128
  }
2094
2129
  }
2095
2130
  if (!body.length) {
@@ -2194,35 +2229,41 @@ function renderUserMessage(msg) {
2194
2229
  ${parts.join("\n")}
2195
2230
  </article>`;
2196
2231
  }
2197
- function renderTurnArticle(turn, blocks, models) {
2232
+ function renderTurnArticle(turn, stepBlocks, answerBlocks, models) {
2198
2233
  const status = statusLabel(turn.status);
2199
2234
  const duration = turn.durationMs !== void 0 ? formatDuration(turn.durationMs) : "";
2200
2235
  const metaParts = [status, duration ? `\u7528\u65F6 ${duration}` : ""].filter(Boolean);
2201
2236
  const metaHtml = metaParts.length ? `<span class="turn-meta">${esc(metaParts.join("\uFF0C"))}</span>` : "";
2202
2237
  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) {
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) {
2206
2246
  return `<article class="msg" data-role="assistant">
2207
- ${blocks.join("\n")}
2247
+ ${inner}
2208
2248
  </article>`;
2209
2249
  }
2210
2250
  return `<article class="msg" data-role="assistant">
2211
2251
  <details class="turn" open>
2212
- ${head}<div class="turn-body">
2213
- ${blocks.join("\n")}
2252
+ <summary class="turn-head">${metaHtml}${modelHtml}</summary>
2253
+ <div class="turn-body">
2254
+ ${inner}
2214
2255
  </div>
2215
2256
  </details>
2216
2257
  </article>`;
2217
2258
  }
2218
- function renderAssistantMessage(msg) {
2259
+ function renderAssistantMessage(msg, flat = false) {
2219
2260
  const parts = [];
2220
2261
  for (const block of msg.blocks) {
2221
- parts.push(renderBlock(block));
2262
+ parts.push(renderBlock(block, flat));
2222
2263
  }
2223
2264
  return parts.filter(Boolean).join("\n");
2224
2265
  }
2225
- function renderBlock(block) {
2266
+ function renderBlock(block, flat = false) {
2226
2267
  switch (block.kind) {
2227
2268
  case "text":
2228
2269
  return `<div class="md">${renderMarkdown(block.md)}</div>`;
@@ -2230,10 +2271,11 @@ function renderBlock(block) {
2230
2271
  return renderDetails({
2231
2272
  kind: "reasoning",
2232
2273
  summary: "\u601D\u8003\u8FC7\u7A0B",
2233
- body: `<div class="md">${renderMarkdown(block.text)}</div>`
2274
+ body: `<div class="md">${renderMarkdown(block.text)}</div>`,
2275
+ open: flat
2234
2276
  });
2235
2277
  case "tool":
2236
- return renderTool(block);
2278
+ return renderTool(block, flat);
2237
2279
  case "retrieval":
2238
2280
  return renderRetrieval(block);
2239
2281
  case "research":
@@ -2251,7 +2293,8 @@ function renderBlock(block) {
2251
2293
  function renderDetails(input) {
2252
2294
  const statusAttr = input.status ? ` data-status="${esc(input.status)}"` : "";
2253
2295
  const nameHtml = input.name ? `<span class="sum-name">${esc(input.name)}</span>` : "";
2254
- return `<details class="process" data-kind="${esc(input.kind)}">
2296
+ const openAttr = input.open ? " open" : "";
2297
+ return `<details class="process" data-kind="${esc(input.kind)}"${openAttr}>
2255
2298
  <summary><span class="sum-text">${esc(input.summary)}</span>${nameHtml}${statusDot(input.status)}</summary>
2256
2299
  <div class="process-body">
2257
2300
  ${input.body}
@@ -2264,7 +2307,7 @@ function statusDot(status) {
2264
2307
  if (status === "pending") return '<span class="sum-state" data-status="pending">\u672A\u5B8C\u6210</span>';
2265
2308
  return "";
2266
2309
  }
2267
- function renderTool(block) {
2310
+ function renderTool(block, flat = false) {
2268
2311
  const summaryText = toolSummary(block);
2269
2312
  const body = [];
2270
2313
  if (block.argsFields?.length) {
@@ -2286,8 +2329,17 @@ function renderTool(block) {
2286
2329
  body.push('<div class="trunc-note">\u4F1A\u8BDD\u5BFC\u51FA\u65F6\u8BE5\u8C03\u7528\u5C1A\u672A\u8FD4\u56DE</div>');
2287
2330
  }
2288
2331
  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
+ }
2289
2341
  return `<details class="process" data-kind="tool" data-tool="${esc(block.name)}">
2290
- <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>
2342
+ <summary>${head}</summary>
2291
2343
  <div class="process-body">
2292
2344
  ${body.join("\n")}
2293
2345
  </div>
@@ -2448,7 +2500,7 @@ function filenameStamp(epochMs, timeZone) {
2448
2500
  }
2449
2501
 
2450
2502
  // src/host/index.ts
2451
- var VERSION = "0.3.0";
2503
+ var VERSION = "0.4.0";
2452
2504
  function exportSession(input) {
2453
2505
  const preset = input.preset ?? "conversation";
2454
2506
  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.0",
3
+ "version": "0.4.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",