@tanzz/dsh-explore 0.1.0 → 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.
Files changed (4) hide show
  1. package/README.md +145 -96
  2. package/README.zh-CN.md +200 -0
  3. package/client.js +2821 -299
  4. package/package.json +2 -2
package/README.md CHANGED
@@ -1,152 +1,201 @@
1
1
  <p align="center">
2
- <img src="assets/hero.svg" width="760" alt="A single line of conversation opens into several branching paths" />
2
+ <img src="assets/hero.svg" width="760" alt="One line of conversation opens into several branching paths" />
3
3
  </p>
4
4
 
5
- <h1 align="center">DSH 探索 · DSH Explore</h1>
5
+ <h1 align="center">DSH Explore</h1>
6
6
 
7
7
  <p align="center">
8
- 把一条对话摊成一张能自己长枝的画布。
9
- <br />
10
8
  A branching-conversation canvas for <b>DeepSeek Harness</b>.
11
9
  </p>
12
10
 
13
- <p align="center">
14
- <img src="https://img.shields.io/badge/license-MIT-3B6FD4" alt="MIT" />
15
- <img src="https://img.shields.io/badge/platform-DeepSeek%20Harness-3B6FD4" alt="DeepSeek Harness" />
16
- </p>
11
+ [![CI](https://github.com/tzzs/dsh-explore/actions/workflows/ci.yml/badge.svg)](https://github.com/tzzs/dsh-explore/actions/workflows/ci.yml)
12
+ [![Release](https://img.shields.io/github/v/release/tzzs/dsh-explore)](https://github.com/tzzs/dsh-explore/releases)
13
+ [![License: MIT](https://img.shields.io/github/license/tzzs/dsh-explore)](LICENSE)
14
+ ![Platform: DeepSeek Harness](https://img.shields.io/badge/platform-DeepSeek%20Harness-3B6FD4)
15
+
16
+ **English** | [简体中文](README.zh-CN.md)
17
17
 
18
18
  ---
19
19
 
20
- ## 这是什么
20
+ ## What it is
21
+
22
+ A conversation in DSH is a line: A → B → C. Real thinking does not look like that — on one answer you often want to ask several unrelated things at once, and once asked they all sink into history with no way to put them side by side.
23
+
24
+ DSH Explore adds an **Infinite Exploration** tab to every conversation: it lays the turns out on an infinite canvas where **any answer can become a fork point**. Ask a follow-up on a node and a new branch grows from it, carrying the full context from the root to that node while leaving its siblings untouched.
21
25
 
22
- DSH 里的对话是一条线:A → B → C。但真实的思考不长这样——同一个回答上,人往往同时想问好几件互不相干的事,问完之后又都压在历史里,没法并排看。
26
+ A branch is not a prompt with history pasted into it. It is a real DSH session created with `ctx.sessions.fork({ sessionId, atSeq })`, so it inherits the exact event prefix up to that answer; tools, approvals, streaming, cancellation and retries all behave like any other conversation.
23
27
 
24
- DSH 探索在你的会话里加一个 **「无限探索」** 页签:把这一轮轮问答铺到一张无限画布上,**任意一个回答都可以成为新的分岔口**。从某个节点再问一句,就长出一根新枝,它带着从根到这里的完整上下文继续往下走,枝条之间互不污染。
28
+ ## Features
25
29
 
26
- ## 功能
30
+ - **Infinite canvas** — drag to pan, scroll to zoom (20%–200%), fit to canvas; the minimap in the bottom-right corner shows the current viewport and jumps on click. On supported DSH layouts, the canvas extends behind the title and composer.
31
+ - **Both tree directions** — the toolbar carries a two-way layout switch: **top to bottom** or **left to right**. Both options are visible at once and the active one is pressed, so the current direction never has to be guessed from the shape of the canvas. The choice is saved in this browser and applies to other conversations.
32
+ - **Adjustable card density** — the toolbar offers three card presets: compact (288px), standard (320px) and roomy (448px). A preset sets both the card width and how many lines of the answer a preview draws; the tree reflows to the chosen width and the choice is remembered. Switch to roomy when the cards feel too small to show a useful answer.
33
+ - **Host appearance** — the interface follows DSH in eight languages (Chinese, English, German, Spanish, French, Japanese, Portuguese, Russian) and in both the light and the dark theme: elevation, overlay surfaces, scrollbars and native form controls are all theme-aware.
34
+ - **Fork from any answer** — the `+` in the corner of a finished card opens an inline composer; press Enter and the new node appears immediately.
35
+ - **Concurrent branches** — several branches can run at once. A running card carries a live progress row (spinner, "Thinking… / Calling read / Writing…", step N, elapsed seconds), renders streamed tokens as Markdown while they arrive, and offers Stop.
36
+ - **You can see what it is thinking** — an elapsed time says the agent is busy, not what it is doing. A running card carries one line of the model's newest thinking; settled, that line becomes "Reasoning · N chars". It is a readout, not a button: the card has exactly one way to enlarge ("Read full screen"), and the reader switches between the final answer and the reasoning inside the same card. The line is always one line, so the card does not move while tokens stream. A model that does not think shows none of this.
37
+ - **Waiting on you** — a branch parked on a question or an approval says so on its card ("Waiting for your answer…" / "Waiting for your approval…") with an accent ring; the canvas expands the path to it and centres it, and the toolbar chip "N waiting on you" jumps there. The path to a running or waiting node is never hidden by the default fold.
38
+ - **Jump to latest** — expands the ancestor path of the newest node and centres that card; newest is judged by creation time, so out-of-order completions cannot send you to a stale card.
39
+ - **Fold and search** — branches at depth 3 and deeper start folded, except on the path to a running or waiting node; `Ctrl/Cmd+F` focuses the search box, and Enter steps through matches, revealing their ancestor paths.
40
+ - **Prompt images stay on the card** — an image attached to a prompt renders as a 48px thumbnail on that card and, in the reader, at its own aspect ratio across the body (60vh tall at most), so a screenshot stays readable. The thumbnail reserves its frame from the image's own dimensions, so the card does not jump when the bytes arrive. A prompt that is only an image still gets a card: the picture is the question, so no "no question" placeholder is printed.
41
+ - **The card previews, the reader reads** — the card keeps the answer to a fixed number of lines with a fade, and there is no in-card "expand answer" any more: expanding there turned the card into a very long strip. The answer, the progress row and the thinking line share one content window: while a branch runs the window has a fixed height, and it settles to its content afterwards, so the canvas does not shake when several branches stream at once. The "Read full screen" button at the bottom is the card's only way in: Esc, the backdrop, or × closes the reader, and the reader itself switches between the final answer and the reasoning, and between a standard and a wider measure.
42
+ - **Branch rows stay out of the workspace** — every new branch is a real session, so DSH lists it as its own row by default. One toolbar chip switches the tree between "Branch rows: in workspace" and "Branch rows: archived" (listed by default; one click archives what already finished and new finished branches follow): archiving moves this tree's finished branch sessions into DSH's archive (the canvas still reads them; the workspace keeps the main session), and switching back restores them. Only finished branches are archived — a running or waiting branch always stays promptable.
43
+ - **Delete and restore** — deleting writes a tombstone and archives the fork's session; the toolbar restores them in one click. The session log itself is never rewritten. A branch the row policy quieted is not owned by that restore: the tombstone brings the node back on the canvas, and switching the branch rows back to the workspace brings its session back to the list.
27
44
 
28
- - **无限画布** —— 拖拽平移、滚轮缩放(10%–200%)、适应画布,右下角小地图可点击跳转并显示当前视口。
29
- - **任意回答开新枝** —— 卡片右上角的 `+` 就是追问入口,就地长出一张输入卡,回车发送后新节点立刻出现。
30
- - **并行分支** —— 几条枝可以同时跑。正在回答的卡片带实时进度行:转圈指示器 +「正在思考… / 正在调用 read / 正在输出…」+ 第 N 步 + 已用秒数,正文按流式 token 边写边渲染,并带「停止」。
31
- - **等你回答** —— 分支停在提问或审批时,卡片改说「等你回答… / 等你授权…」并带一圈强调边框;画布自动展开到它并居中,工具条上的「N 个在等你」可点击跳转。正在跑的节点所在路径不会被默认折叠藏起来。
32
- - **定位最新** —— 一键展开到最新节点的祖先路径并把那张卡片居中;最新按创建时间判定,并行完成顺序打乱也不会跳错。
33
- - **折叠与搜索** —— 第三层起默认折叠,但通往「正在跑 / 在等你」节点的路径始终展开;`Ctrl/Cmd+F` 聚焦搜索框,回车逐个跳转命中节点并自动展开祖先路径。
34
- - **全屏阅读** —— 点卡片正文打开阅读层(Esc / 点背景 / × 关闭),长回答不用挤在 320px 里。
35
- - **删除与恢复** —— 删除只写墓碑并归档对应的 fork 会话,工具栏可一键恢复;会话日志本身从不改写。
45
+ ## Requirements
36
46
 
37
- ## 安装
47
+ - **DeepSeek Harness**, desktop or web, on a profile that allows installing plugins.
48
+ - **Node.js 22+** — development only. The plugin has no build step and no npm dependencies of its own.
38
49
 
39
- 前置:**DeepSeek Harness**(桌面版或 Web 版),且 profile 允许安装插件。
50
+ ## Install
40
51
 
41
- 插件发布在 npm,包名 `@tanzz/dsh-explore`。在 DSH 里安装:
52
+ The plugin is published to npm as `@tanzz/dsh-explore`. Install it through DSH's plugin manager:
42
53
 
43
- 1. 打开插件管理(`plugin_manager`)→ `install_bundle`;
44
- 2. `target` 填包名 `@tanzz/dsh-explore`;要锁版本就写 `@tanzz/dsh-explore@0.1.0`;
45
- 3. 安装完成后,会话页签里会多出「无限探索」。
54
+ 1. Open the plugin manager (`plugin_manager`) → `install_bundle`.
55
+ 2. Set `target` to `@tanzz/dsh-explore`; pin a version with `@tanzz/dsh-explore@0.1.0`.
56
+ 3. When it finishes, the conversation tabs include 「无限探索」 / Infinite Exploration.
46
57
 
47
- > 包名是 `@tanzz/dsh-explore`。它是安装标识,不是展示名:展示名来自 `locale/`,中文「DSH 探索」、英文「DSH Explore」。npm 上不带作用域的 `dsh-explore` 已被另一个无关项目占用,所以这里用 npm 用户名作用域。
58
+ > The package name is an install identifier, not a display name: the display name comes from `locale/` — 「DSH 探索」 in Chinese, DSH Explore in English. npm's unscoped `dsh-explore` is taken by an unrelated project, so the package lives under the user scope.
48
59
 
49
- 改代码时不必走 npm:克隆仓库,让 `install_bundle` 的 `target` 直接填**这个目录的绝对路径**(profile 里会记成 `link:` 依赖),改完热更新。
60
+ To work on the plugin itself, install the clone instead — the profile records it as a `link:` dependency, and edits hot-swap:
50
61
 
51
62
  ```bash
52
63
  git clone https://github.com/tzzs/dsh-explore.git
53
- # target 填这个目录,例如 E:\workspaces\dsh-explore
64
+ # target: the absolute path, e.g. E:\workspaces\dsh-explore
65
+ ```
66
+
67
+ To install a specific release without npm, download the `.tgz` attached to that GitHub Release and point `install_bundle` at the unpacked `package` directory:
68
+
69
+ ```bash
70
+ mkdir dsh-explore-release
71
+ tar -xzf tanzz-dsh-explore-0.1.0.tgz -C dsh-explore-release
72
+ # target: <absolute path>/dsh-explore-release/package
54
73
  ```
55
74
 
56
- ## 命名
75
+ ## Naming
57
76
 
58
- 四层名字各管一件事,刻意不互相套用:
77
+ Four layers, four jobs, deliberately not collapsed into one name:
59
78
 
60
- | 层 | 名字 | 出现在哪 | 为什么是这个 |
79
+ | Layer | Name | Where it appears | Why this one |
61
80
  |---|---|---|---|
62
- | 仓库 | `dsh-explore` | GitHub URL、`git clone` | 公开地址,一旦发布就不改;短、全小写、无空格 |
63
- | 包 | `@tanzz/dsh-explore` | `package.json`、npm registry、profile 依赖 | 与仓库同名,安装时一眼对得上;npm 上 `dsh-explore` 被占用,所以用作用域;改它要卸载重装 |
64
- | 插件(展示名) | 「DSH 探索」/ `DSH Explore` | 插件列表、设置页 | 人读的产品名;前缀 `DSH` 说明它属于哪个宿主 |
65
- | 视图(页签) | 「无限探索」/ `Infinite Exploration` | 会话里的第三个页签 | 描述这个视图在做什么,不是产品名;跟随界面语言切换 |
81
+ | Repository | `dsh-explore` | GitHub URL, `git clone` | the public address; short, lowercase, no spaces, and it does not change after release |
82
+ | Package | `@tanzz/dsh-explore` | `package.json`, npm registry, the profile's dependency | matches the repo, so an install is easy to trace; npm's unscoped `dsh-explore` is taken, so it uses the user scope; renaming it means uninstall and reinstall |
83
+ | Plugin (display name) | DSH Explore / 「DSH 探索」 | plugin list, settings page | the product name a human reads; the `DSH` prefix says which host it belongs to |
84
+ | View (tab) | Infinite Exploration / 「无限探索」 | the third tab inside a conversation | describes what the view does, not the product; follows the UI language |
66
85
 
67
- 「无限探索」是**视图名**而不是插件名,所以没有把它并进展示名(「DSH 无限探索」会让产品名和页签名撞在一起,英文也会变成冗长的 `DSH Infinite Exploration`)。同理没有把页签改成 `Explore`——那会丢掉「无限」这层意思,而画布确实是无限延展的。
86
+ The tab is a **view name**, so it is not folded into the display name — "DSH Infinite Exploration" would collide with the tab and read badly in both languages. Nor is the tab shortened to `Explore`: that drops the "infinite" part, and the canvas really does extend without bound.
68
87
 
69
- ## 目录结构
88
+ ## Project layout
70
89
 
71
90
  ```
72
- client.js 客户端视图:事件投影、布局、画布、卡片、阅读层
73
- index.js 宿主侧空实现(这个插件只在客户端做事)
74
- cordis.patch.yml 向 profile 插入一行 dsh-explore
75
- locale/zh.json 中文展示名与描述
76
- locale/en.json 英文展示名与描述
77
- icon.svg 插件图标
78
- assets/hero.svg README 头图(一条线分出多条路径)
79
- test/render-smoke.cjs 渲染冒烟测试(假 React + 假 DOM,断言中英两套文案)
80
- test/theme-tokens.cjs 主题守卫测试(禁止写死色值,检查关键 token 配对)
81
- docs/design.md 设计文档:数据模型、取舍、已知缺口
91
+ client.js client view: event projection, layout, canvas, cards, reader overlay
92
+ index.js host half, an empty apply() — all the work happens in the client
93
+ cordis.patch.yml inserts the dsh-explore row into the DSH profile
94
+ locale/zh.json Chinese display name and description
95
+ locale/en.json English display name and description
96
+ icon.svg plugin icon
97
+ assets/hero.svg README hero: one line branching into several paths
98
+ test/render-smoke.cjs renders the whole view with a fake React and asserts both language tables
99
+ test/canvas-visibility.cjs running/waiting nodes must be laid out and drawn; waiting copy; projection whitelist
100
+ test/session-rebind.cjs re-subscribe on a new eventSource, no pruning on an empty window, cold session open()
101
+ test/theme-tokens.cjs no literal colours, required tokens exist, inverted primary-button foreground
102
+ test/motion.cjs camera interpolation, gesture interruption, navigation replacement, reduced motion
103
+ test/wheel-scroll.cjs the canvas yields the wheel to inner scroll areas and stops at their ends
104
+ test/live-clock.cjs the running card counts wall clock, and only one timer exists
105
+ test/reader-dialog.cjs the reader is a native modal: no hand-built focus trap, contained scroll
106
+ test/card-display.cjs three card densities, no in-card expand, reader width presets and geometry
107
+ test/card-reading.cjs a card that does not move while it streams, one enlarge entry, two reader panes
108
+ test/card-attachments.cjs prompt images: attachment refs projected and persisted, card thumbnails, image-only prompts
109
+ test/branch-sessions.cjs branch archive policy: finished only, switchable, unarchived around a fork
110
+ test/branch-archive-flow.cjs archive flow end to end: only after the turn, both switch directions, tombstone isolation
111
+ test/markdown-table.cjs GFM tables: alignment, escaped pipes, scrollable wrapper
112
+ test/markdown.cjs the whole supported Markdown surface, plus what it refuses
113
+ test/layout-direction.cjs horizontal and vertical geometry, unequal heights, collapsed branches
114
+ test/host-overlay.cjs conversation overlay, chrome measurement, reader and fallback
115
+ test/locale-parity.cjs all eight dictionaries: same key set, aligned {placeholders}, no cross-script leakage
116
+ test/reasoning.cjs the reasoning card: live line, reader panes, no-reasoning, retry, cap, truthful count
117
+ test/reasoning-persist.cjs reasoning stays out of the snapshot and is re-derived after a reload
118
+ test/real-log.cjs end-to-end harness over a real session.v4.jsonl.zstd
119
+ docs/design.md design doc: data model, trade-offs, known gaps
120
+ docs/releasing.md CI, Release Please and npm publishing
121
+ .github/workflows/ CI, Release Please and the manual npm publish workflow
82
122
  ```
83
123
 
84
- ## 实现要点
124
+ ## How it works
85
125
 
86
- - **注册点**:`conversation.view`,`id: tree`、`order: 5`、`label` 是一个 thunk(每次投影重新求值),与 Chat / Trajectory 并列。
87
- - **界面文案跟随宿主语言**:所有可见文本都是 `dsh-explore` 命名空间下的键,通过客户端 locale 服务查表;切换语言时页签标题和整个视图一起切换。没有 locale 插件的 profile 会退回内置的中英表(按 `document.documentElement.lang` 选择)。
88
- - **节点是日志的投影**:读取会话的 `entries`(持久事件 + 暂态 `assistant/live-chunk`),把一个 turn 投影成一张卡片;不额外写记录,所以在 Chat 里继续聊,树上就会自然长节点。
89
- - **等待态没有专门事件**:宿主里 `ask_user_question` 与审批都只是「工具还没返回」——等回答期间不发 `turn/end`,`running` 也保持 `true`。插件用 `tool/call` 的 `ask_user_question`(`callId` 在 `tool/result` 里结清)和 `approval/asked → approval/decided` 算出「在等你」,把卡片从「正在调用工具」改成「等你回答 / 等你授权」。`user/message` 的 `source.kind` 只有 `user` 与 `user-question-reply` 两种,投影两端都认。
90
- - **正在跑的路径不折叠**:布局只走「未折叠」的节点,被折叠的节点连位置都没有、根本不会被画。所以通往「正在跑 / 在等你」节点的祖先路径一律不套用默认折叠;节点进入运行态时还会把路径展开并持久化,停在等用户时再把画布移过去。工具条上的运行计数与「在等你」计数都是跳转按钮。
91
- - **会话会被重新绑定**:离开对话后宿主会释放它的引用,引用归零时 scope 被回收、`Session` 实例连同事件窗口一起丢掉;再进来时 `materializeScope` 会造一个新的 `eventSource`,窗口从空开始。所以订阅跟着 `eventSource` 换(旧的自动退订)、空窗口不当作「会话是空的」去剪枝、冷会话主动 `open()` 一次——否则直接在「无限探索」页签上切回来会得到一张空画布,而先点「回对话」再切回来又正常。`test/session-rebind.cjs` 守住这条。
92
- - **分叉是真实会话**:`ctx.sessions.fork({ sessionId, atSeq })`,子会话天然继承到该回答为止的前缀上下文;每根枝会出现在会话列表里,插件会把它改名成 `⟂ 父问题 · 新问题` 便于辨认。
93
- - **父子关系存在本地**:这一版 fork 不记录 `parentSession`,树形关系由插件在 `localStorage` 里维护(同时缓存折叠状态、墓碑、卡片高度)。
94
- - **主题**:颜色全部使用 `--dsw-alias-*` CSS 变量,浅色 / 深色主题自动跟随,不写死色值。主按钮的 `--dsw-alias-brand-primary` 在深浅主题下会反相(浅色近黑、深色近白),所以文字必须用配套的 `--dsw-alias-label-primary-foreground`,不能写死 `#fff`;行内代码用 `label-primary` 的 7% 着色(官方 inline-code token 在浅色下几乎是白的,放在白卡片上会看不见)。字体接组合后的 `--dsw-font-family` / `--ds-font-family-code`——DSH 已把用户字体和内置默认栈拼在一起,直接读组合 token 才能保住字形回退。`test/theme-tokens.cjs` 守住这些规则。
126
+ The view is a single client plugin; the full design — data model, trade-offs, known gaps — is in [docs/design.md](docs/design.md) (currently in Chinese).
95
127
 
96
- ## 开发
128
+ - **Registration.** One `conversation.view` slot: `id: 'tree'`, `order: 5`, and a `label` thunk that is re-evaluated on every projection, next to Chat and Trajectory.
129
+ - **Copy follows the host language.** Every visible string is a key in the `dsh-explore` namespace resolved through the client locale service, so switching language swaps the tab title and the whole view. A profile without the locale plugin falls back to the built-in Chinese/English tables, chosen by `document.documentElement.lang`.
130
+ - **Nodes are projections.** The view reads a session's `entries` (durable events plus the transient `assistant/live-chunk`) and projects one turn onto one card. Nothing extra is recorded, so continuing the chat in Chat simply grows the tree.
131
+ - **"Waiting on you" has no event of its own.** In the host, `ask_user_question` and approvals are just "a tool that has not returned yet": no `turn/end` is emitted while waiting and `running` stays `true`. The plugin derives the state from `tool/call` (`ask_user_question`, settled by `callId` in `tool/result`) and `approval/asked → approval/decided`, and relabels the card from calling a tool to waiting. `user/message` only ever carries `source.kind: 'user'` or `'user-question-reply'`, and both are projected.
132
+ - **Reasoning is visible, and it is already in the event window.** The model writes its thinking as `reasoning` content blocks — live as a `reasoning-delta` chunk on the transient `assistant/live-chunk`, settled as `{ type: 'reasoning', text }` inside the durable `assistant/message`. Both reach the plugin unchanged, so one projection covers "thinking now" and "done thinking": while a branch runs the card shows the newest line, and once it settles that line becomes the character count; the whole chain is one deliberate switch away in the reader. A model that does not think renders nothing. A retry reuses the same turn/step, so the failed attempt's thinking is dropped first. Each card keeps at most 12000 characters, and the dropped count is derived from the bytes each block delivered (`received − kept`) rather than accumulated, because a block is trimmed more than once. Reasoning is **not** persisted to `localStorage`: it is re-derived from the log, and that snapshot also holds the parent links, which cannot be rebuilt.
133
+ - **Attached images are content blocks, not text.** A `user/message` carries `content` as an array. Text is one kind of block and an attachment is another: `{ type: 'image', attachment: { attachmentId, mediaType, width, height, bytes, name } }` sits beside the text, so `textOf` never sees it. The projection keeps the refs in content order, an image-only prompt is admitted as a real question, and the refs ride in the snapshot because each one is a few hundred bytes while the image itself stays with the host. Rendering asks the host's authorized reader for the node's session: `peekImageUrl` first, which is why a re-opened card paints its thumbnails without a flash, then `imageUrl` when nothing is cached. That service is read defensively and stays out of the plugin's `inject` list, so a host without it loads the view with no thumbnails rather than failing.
134
+ - **The path to an active node is never folded.** Layout only walks unfolded nodes, and a folded node has no position and is never drawn — that was the root cause of "the canvas does not show the node that is running". So the ancestor path of a running or waiting node skips the default fold; a node entering the running state also expands and persists that path, and a node that starts waiting moves the canvas onto itself. The toolbar's running count and "waiting on you" count are both jump buttons.
135
+ - **Sessions get re-bound.** Leaving a conversation drops the host's reference; at zero the scope is collected and the `Session` instance is discarded together with its event window. On the way back, `materializeScope` mints a new `eventSource` and the window starts empty. Subscriptions therefore follow `eventSource` (the old one unsubscribes), an empty window is never treated as "the session is empty" and pruned, and a cold session is `open()`ed once — otherwise returning straight to the tab gives a blank canvas while Chat-then-tab works. `test/session-rebind.cjs` pins this.
136
+ - **Forks are real sessions.** `ctx.sessions.fork({ sessionId, atSeq })` gives the child the prefix context up to that answer. Each branch also lands in the session list, so it is renamed `⟂ parent question · new question` to stay recognisable. A client plugin cannot make that row a nested "subtask" — only host subagent sessions get hidden/nested rows — so the tree offers the one supported lever: a finished branch can be archived (readable, no longer listed, no longer promptable) and the toolbar switches the whole tree between listed and archived. `quieted` is tracked separately from the deletion tombstones so restoring a deleted node never surfaces a branch the policy quieted.
137
+ - **Parent links live locally.** This DSH build does not record `parentSession`, so the plugin keeps the tree in `localStorage`, alongside fold state, tombstones and the layout preference. Card heights are measured at runtime.
138
+ - **Theme.** All colours are `--dsw-alias-*` variables, so light and dark follow the host and no literal value is written. `--dsw-alias-brand-primary` inverts between themes, so primary-button text must use the matching `--dsw-alias-label-primary-foreground` rather than `#fff`; inline code is tinted with 7% `label-primary` because the official inline-code token is nearly white in light mode. Fonts read the composed `--dsw-font-family` / `--ds-font-family-code` tokens, which already join the user's font with the built-in fallback stack. `test/theme-tokens.cjs` guards all of it.
139
+
140
+ ## Development
97
141
 
98
142
  ```bash
99
- npm test # 下面六条一起跑(package.json 里的 scripts.test)
100
-
101
- node --check client.js # 语法
102
- node test/render-smoke.cjs # 渲染冒烟:把整个视图真渲染一遍,并断言中英两套文案
103
- node test/canvas-visibility.cjs # 可见性回归:在跑/等你的节点必须被画出来,等待态文案与投影白名单
104
- node test/session-rebind.cjs # 重新打开会话:scope 重建后换订阅、空窗口不剪枝、冷会话要 open
105
- node test/theme-tokens.cjs # 主题守卫:色值不写死、token 必须存在、主按钮用反相前景 token
106
- node test/motion.cjs # 动效:画布移动、手势中断、导航替换、减少动态效果与清理
143
+ npm test # every command below (scripts.test in package.json)
144
+
145
+ node --check client.js # syntax
146
+ node test/render-smoke.cjs # render the whole view with a fake React; assert both language tables
147
+ node test/canvas-visibility.cjs # running/waiting nodes must be laid out and drawn; waiting copy; projection whitelist
148
+ node test/session-rebind.cjs # re-subscribe after a scope rebuild; no pruning on an empty window; cold session open()
149
+ node test/theme-tokens.cjs # no literal colours, tokens exist, primary buttons use the inverted foreground
150
+ node test/motion.cjs # camera moves, gesture interruption, navigation replacement, reduced motion, cleanup
151
+ node test/wheel-scroll.cjs # the wheel belongs to the reasoning box, not the canvas zoom
152
+ node test/live-clock.cjs # the elapsed time advances between events, from one timer
153
+ node test/reader-dialog.cjs # the reader is a native <dialog>: showModal, close mirroring, backdrop scroll containment
154
+ node test/card-display.cjs # three card densities, no in-card expand, reader width presets and reflow geometry
155
+ node test/card-reading.cjs # a card that does not move while it streams, one enlarge entry, two reader panes
156
+ node test/card-attachments.cjs # prompt images: attachment refs projected and persisted, thumbnails, image-only prompts
157
+ node test/branch-sessions.cjs # finished branches only, switchable policy, unarchived around a fork
158
+ node test/branch-archive-flow.cjs # archive flow end to end: only after the turn, both directions, tombstone isolation
159
+ node test/markdown-table.cjs # GFM tables in answers
160
+ node test/markdown.cjs # every Markdown construct the renderer supports
161
+ node test/layout-direction.cjs # geometry in both directions, unequal heights, collapsed branches
162
+ node test/host-overlay.cjs # host overlay, chrome measurement, reader, fallback
163
+ node test/locale-parity.cjs # all eight dictionaries agree on keys, placeholders and script
164
+ node test/reasoning.cjs # reasoning: live line, reader panes, no-reasoning, retry, cap, truthful count
165
+ node test/reasoning-persist.cjs # reasoning stays out of the snapshot; re-derived after reload; parent links survive
107
166
  ```
108
167
 
109
- `client.js` 是客户端插件(`window.__ModuleLoader__.load` 的惰性工厂),改完客户端热更新立即生效。注意样式表在每次 `apply()` 都会重写同一个 `<style>` 节点——如果只在节点已存在时跳过,热更新后的新规则永远不会生效。
168
+ `node test/real-log.cjs <a session.v4.jsonl.zstd>` replays a real session end to end; it is optional and not part of `npm test`.
110
169
 
111
- ## CI 与发版
170
+ `client.js` is a client plugin — the lazy factory behind `window.__ModuleLoader__.load` — and edits hot-swap into the running host without a page reload. Note that the stylesheet rewrites the same `<style>` node on every `apply()`: skipping the rewrite when the node already exists means new rules never take effect after a hot reload.
112
171
 
113
- 向 `main` 提 PR 时,GitHub Actions 会在 Ubuntu / Windows、Node.js 22 / 24 上执行测试与打包预检;推送到 `main` 时,发版工作流先运行同一套检查,再由 Google Release Please 创建或更新发版 PR。
172
+ ## CI & releases
114
173
 
115
- 合并发版 PR 后自动创建 `v<version>` tag、GitHub Release,并附上可解压后本地安装的插件 `.tgz` 包,同一 commit 还会以 `--provenance` 发布到 npm。首版为 `v0.1.0`,后续版本由 Conventional Commits 决定。
174
+ A PR to `main` runs `.github/workflows/ci.yml` on Ubuntu and Windows with Node.js 22 and 24: `node --check index.js`, `npm test`, `npm pack --dry-run`. There is no install step — the plugin and its tests have no npm dependencies, and there is no lockfile.
116
175
 
117
- 启用前请查看 [CI 与自动发版说明](docs/releasing.md),完成仓库 Actions 权限、`RELEASE_PLEASE_TOKEN` 与 npm 发布凭证配置。
176
+ Releases are driven by Conventional Commits through Google's Release Please: it opens or updates a release PR that bumps `package.json`, the manifest and `CHANGELOG.md`; merging it starts the release job, which runs the full matrix on the released commit, packs `tanzz-dsh-explore-<version>.tgz`, attaches it to the GitHub Release, publishes the release, lets GitHub create the `v<version>` tag, and publishes the same commit to npm with provenance. `@tanzz/dsh-explore@0.1.0` is the published baseline; later versions publish automatically from that workflow.
118
177
 
119
- ## 已知限制
178
+ See [CI and releases](docs/releasing.md) (currently in Chinese) for first-time setup — Actions permissions, the optional `RELEASE_PLEASE_TOKEN` secret, and npm Trusted Publishing.
120
179
 
121
- - **树关系只在这台机器的这个浏览器里**:换浏览器、清站点数据或换 profile,树枝会平掉(每个会话自己那条链还在,但接不回同一棵树)。
122
- - **树是会话级的**:没有「把几棵树摆在一起」的本子。
123
- - **出错**:出错只体现在卡片状态上,不会自动跳过去;提问和审批则会(见「等你回答」)。
124
- - **插件之外的 fork**:在 DSH 里、插件之外 fork 出来的会话识别不到,会被当成新树的根。
180
+ ## Contributing
125
181
 
126
- ## License
182
+ See [CONTRIBUTING.md](CONTRIBUTING.md). Commit messages and PR titles follow [Conventional Commits](https://www.conventionalcommits.org/) — Release Please derives the next version from them — and bug reports and feature requests have issue templates.
127
183
 
128
- [MIT](LICENSE) © 2026 tzzs
129
-
130
- ---
184
+ ## Security
131
185
 
132
- ## English
186
+ See [SECURITY.md](SECURITY.md) for how to report a vulnerability privately. Please do not open a public issue for one.
133
187
 
134
- **DSH Explore**(DSH 探索)adds an **Infinite Exploration** tab to every DeepSeek Harness conversation: it lays the turns out on an infinite canvas where **any answer can become a fork point**. Ask a follow-up there and a new branch grows, carrying the full prefix context of the path that led to it, without contaminating its siblings.
188
+ ## Limitations
135
189
 
136
- - Infinite pan/zoom canvas with a clickable minimap that also shows the current viewport.
137
- - `+` on any finished answer opens an inline composer; the new node appears immediately.
138
- - Several branches run concurrently, each with a live progress row (thinking / tool name / step / elapsed) and a stop button; streamed tokens render as Markdown while they arrive.
139
- - **Waiting on you** — a branch parked on a question or an approval says so on its card (「等你回答…」/「等你授权…」 with an accent ring); the canvas opens the path to it and centres it, and the toolbar's "waiting on you" chip jumps to it. The path to a node that is running is never hidden by the default fold.
140
- - **Jump to latest** expands the ancestor path and centres the newest node; newest is judged by creation time, so out-of-order completions cannot send you to a stale card.
141
- - Depth-3 branches start folded — except on the path to a running or waiting node; `Ctrl/Cmd+F` searches nodes and reveals the ancestor path.
142
- - Click the answer body for a full-screen reader; deleting is a tombstone plus archiving the fork's session, and it is reversible.
190
+ - **The tree relationship lives in this browser on this machine.** Another browser, cleared site data or another profile flattens the tree: each session keeps its own chain, but the branches cannot be reattached.
191
+ - **A tree is per session.** There is no notebook that puts several trees side by side.
192
+ - **Errors stay on the card.** A failed turn shows its state there and does not pull the canvas over to itself; questions and approvals do.
193
+ - **Forks made outside the plugin are invisible.** A session forked in DSH by other means is opened as the root of a new tree.
143
194
 
144
- **Install** — install `@tanzz/dsh-explore` from npm with DSH's plugin manager (`install_bundle`, `target = @tanzz/dsh-explore`, or pin a version such as `@tanzz/dsh-explore@0.1.0`). For local development, clone this repo and point `install_bundle` at the absolute directory instead; the tab shows up as「无限探索」.
145
-
146
- **Tech** — `client.js` registers `conversation.view` (`id: tree`); nodes are projections of session events (`entries`, including transient `assistant/live-chunk`); forks are real sessions created with `ctx.sessions.fork({ sessionId, atSeq })`; parent links live in `localStorage` because this DSH build does not record `parentSession`; a pending `ask_user_question` / approval has no event of its own — the projection derives "waiting on you" from `tool/call` + `approval/asked` (and the turn staying open), and the layout never folds the path to an active node; all colours use `--dsw-alias-*` theme tokens (including the inverted `--dsw-alias-label-primary-foreground` on primary buttons), and font families read the composed `--dsw-font-family` / `--ds-font-family-code` tokens so a custom font keeps DSH's fallback stack.
195
+ ## License
147
196
 
148
- **CI & releases** — PRs and `main` run tests on Ubuntu / Windows with Node.js 22 / 24. Google Release Please maintains a release PR; merging it creates a version tag and GitHub Release with a plugin `.tgz` attachment, then publishes the same commit to npm with provenance. See the [release setup guide](docs/releasing.md) for Actions permissions and the `RELEASE_PLEASE_TOKEN` / npm publishing setup.
197
+ [MIT](LICENSE) © 2026 tzzs
149
198
 
150
- **Limits** — the tree relationship is local to this browser; there is no cross-session notebook; errors only show on the card (questions and approvals do jump into view); sessions forked outside the plugin cannot be attached to a tree.
199
+ [MIT](LICENSE) © 2026 tzzs
151
200
 
152
- Licensed under [MIT](LICENSE).
201
+ By participating you agree to the [Code of Conduct](CODE_OF_CONDUCT.md).
@@ -0,0 +1,200 @@
1
+ <p align="center">
2
+ <img src="assets/hero.svg" width="760" alt="一条对话分出多条路径" />
3
+ </p>
4
+
5
+ <h1 align="center">DSH 探索</h1>
6
+
7
+ <p align="center">
8
+ 把一条对话摊成一张能自己长枝的画布。<b>DeepSeek Harness</b> 的分支对话插件。
9
+ </p>
10
+
11
+ [![CI](https://github.com/tzzs/dsh-explore/actions/workflows/ci.yml/badge.svg)](https://github.com/tzzs/dsh-explore/actions/workflows/ci.yml)
12
+ [![Release](https://img.shields.io/github/v/release/tzzs/dsh-explore)](https://github.com/tzzs/dsh-explore/releases)
13
+ [![License: MIT](https://img.shields.io/github/license/tzzs/dsh-explore)](LICENSE)
14
+ ![Platform: DeepSeek Harness](https://img.shields.io/badge/platform-DeepSeek%20Harness-3B6FD4)
15
+
16
+ [English](README.md) | **简体中文**
17
+
18
+ ---
19
+
20
+ ## 这是什么
21
+
22
+ DSH 里的对话是一条线:A → B → C。但真实的思考不长这样——同一个回答上,人往往同时想问好几件互不相干的事,问完之后又都压在历史里,没法并排看。
23
+
24
+ DSH 探索在每个会话里加一个 **「无限探索」** 页签:把一轮轮问答铺到一张无限画布上,**任意一个回答都可以成为新的分岔口**。从某个节点再问一句,就长出一根新枝,它带着从根到这里的完整上下文继续往下走,枝条之间互不污染。
25
+
26
+ 新枝不是把历史拼进 prompt,而是 `ctx.sessions.fork({ sessionId, atSeq })` 建出来的真实会话:它原样继承到该回答为止的事件前缀,工具、审批、流式、取消、重试都和普通会话一样。
27
+
28
+ ## 功能
29
+
30
+ - **无限画布** —— 拖拽平移、滚轮缩放(20%–200%)、适应画布,右下角小地图可点击跳转并显示当前视口。在支持的 DSH 页面布局中,画布延伸到标题和输入框后方。
31
+ - **两个方向都支持** —— 工具栏上是双向的布局开关:**从上到下** 或 **从左到右**。两个选项同时可见,当前那个是按下态,所以不用靠画布形状去猜现在朝哪个方向。选择保存在当前浏览器中,对其他会话也生效。
32
+ - **卡片信息量可调** —— 工具栏「卡片信息量」三档:紧凑(288px)/ 标准(320px)/ 宽松(448px)。档位同时决定卡片宽度和预览的行数,整棵树按新宽度重排并记住你的选择;觉得卡片太小、看不到几句回答时,切到宽松。
33
+ - **跟随宿主外观** —— 界面跟随 DSH 的八种语言(中、英、德、西、法、日、葡、俄)和浅色 / 深色主题:层级阴影、浮层背景、滚动条和原生表单控件都随主题走。
34
+ - **任意回答开新枝** —— 卡片右上角的 `+` 就是追问入口,就地长出一张输入卡,回车发送后新节点立刻出现。
35
+ - **并行分支** —— 几条枝可以同时跑。正在回答的卡片带实时进度行:转圈指示器 +「正在思考… / 正在调用 read / 正在输出…」+ 第 N 步 + 已用秒数,正文按流式 token 边写边渲染,并带「停止」。
36
+ - **看得见在想什么** —— 光有耗时看不出智能体在忙什么。正在跑的卡片底部有一条单行思考行,实时显示模型最新写下的一行;停下来之后同一行改成「思考过程 · N 字」。它是状态,不是按钮——卡片上唯一能放大的是「全屏阅读」,阅读层里用「最终结果 / 思考过程」在一张卡片里读两面。这一行永远只有一行,所以流式输出时卡片高度不跳。模型不思考就不显示。
37
+ - **等你回答** —— 分支停在提问或审批时,卡片改说「等你回答… / 等你授权…」并带一圈强调边框;画布自动展开到它并居中,工具条上的「N 个在等你」可点击跳转。正在跑的节点所在路径不会被默认折叠藏起来。
38
+ - **定位最新** —— 一键展开到最新节点的祖先路径并把那张卡片居中;最新按创建时间判定,并行完成顺序打乱也不会跳错。
39
+ - **折叠与搜索** —— 第三层起默认折叠,但通往「正在跑 / 在等你」节点的路径始终展开;`Ctrl/Cmd+F` 聚焦搜索框,回车逐个跳转命中节点并自动展开祖先路径。
40
+ - **提示里的附图会留在卡片上** —— 附在提示里的图片在卡片上是高 48px 的缩略图,在阅读层里铺在正文顶部、按图片自身比例缩放(最高 60vh),截图也读得清;缩略图按图片自身尺寸预留占位框,图片到达前后卡片不会跳一下。只带图片、没有文字的提示同样有卡片:图就是问题,不再印「(无问题)」。
41
+ - **卡片只做预览,全文进阅读层** —— 卡片上的回答按档位截到固定行数并淡出,不再有「展开回答」——在卡片里展开会把卡片拉成很长的竖条。回答、进度行和思考行装在同一个内容窗里:跑的时候窗口有固定高度,落定后收成内容高度,所以几条枝同时流式时画布不抖。点底部的「全屏阅读」按钮打开阅读层(卡片上唯一的放大入口):Esc / 点背景 / × 关闭,阅读层里能在「标准宽 / 较宽」之间切换,长回答不必挤在窄栏里。
42
+ - **分支记录不占工作区** —— 每根新枝都是一个真实会话,所以 DSH 默认会在工作区里为它列一行。工具栏的「分支记录:在工作区 / 已归档」一键切换(默认在工作区,点一下即收起本树已完成的记录,之后新完成的枝也自动归档):切到已归档会把本树已完成的分支会话收进 DSH 归档(画布照常读取,工作区只留主会话),切回来再逐条恢复;归档只针对已完成的分支,正在跑或等你的分支始终留在外面。
43
+ - **删除与恢复** —— 删除只写墓碑并归档对应的 fork 会话,工具栏可一键恢复;会话日志本身从不改写。被「分支记录」收进归档的分支不归恢复管——恢复墓碑只还原画布上的节点,要让它回到工作区列表,把「分支记录」切回在工作区即可。
44
+
45
+ ## 环境要求
46
+
47
+ - **DeepSeek Harness**(桌面版或 Web 版),且 profile 允许安装插件。
48
+ - **Node.js 22+** —— 只用于开发;插件没有构建步骤,也没有自己的 npm 依赖。
49
+
50
+ ## 安装
51
+
52
+ 插件发布在 npm,包名 `@tanzz/dsh-explore`。在 DSH 里安装:
53
+
54
+ 1. 打开插件管理(`plugin_manager`)→ `install_bundle`;
55
+ 2. `target` 填包名 `@tanzz/dsh-explore`;要锁版本就写 `@tanzz/dsh-explore@0.1.0`;
56
+ 3. 安装完成后,会话页签里会多出「无限探索」/ Infinite Exploration。
57
+
58
+ > 包名是安装标识,不是展示名:展示名来自 `locale/`,中文「DSH 探索」、英文「DSH Explore」。npm 上不带作用域的 `dsh-explore` 已被另一个无关项目占用,所以这里用 npm 用户名作用域。
59
+
60
+ 改插件本身时不必走 npm:克隆仓库,让 `install_bundle` 的 `target` 直接填**这个目录的绝对路径**(profile 里会记成 `link:` 依赖),改完热更新。
61
+
62
+ ```bash
63
+ git clone https://github.com/tzzs/dsh-explore.git
64
+ # target 填这个目录,例如 E:\workspaces\dsh-explore
65
+ ```
66
+
67
+ 要装某个具体版本又不想走 npm,下载那个 Release 的 `.tgz` 附件,解压后把 `package` 目录的绝对路径交给 `install_bundle`:
68
+
69
+ ```bash
70
+ mkdir dsh-explore-release
71
+ tar -xzf tanzz-dsh-explore-0.1.0.tgz -C dsh-explore-release
72
+ # 安装目录:<绝对路径>/dsh-explore-release/package
73
+ ```
74
+
75
+ ## 命名
76
+
77
+ 四层名字各管一件事,刻意不互相套用:
78
+
79
+ | 层 | 名字 | 出现在哪 | 为什么是这个 |
80
+ |---|---|---|---|
81
+ | 仓库 | `dsh-explore` | GitHub URL、`git clone` | 公开地址,一旦发布就不改;短、全小写、无空格 |
82
+ | 包 | `@tanzz/dsh-explore` | `package.json`、npm registry、profile 依赖 | 与仓库同名,安装时一眼对得上;npm 上 `dsh-explore` 被占用,所以用作用域;改它要卸载重装 |
83
+ | 插件(展示名) | 「DSH 探索」/ `DSH Explore` | 插件列表、设置页 | 人读的产品名;前缀 `DSH` 说明它属于哪个宿主 |
84
+ | 视图(页签) | 「无限探索」/ `Infinite Exploration` | 会话里的第三个页签 | 描述这个视图在做什么,不是产品名;跟随界面语言切换 |
85
+
86
+ 「无限探索」是**视图名**而不是插件名,所以没有把它并进展示名(「DSH 无限探索」会让产品名和页签名撞在一起,英文也会变成冗长的 `DSH Infinite Exploration`)。同理没有把页签改成 `Explore`——那会丢掉「无限」这层意思,而画布确实是无限延展的。
87
+
88
+ ## 目录结构
89
+
90
+ ```
91
+ client.js 客户端视图:事件投影、布局、画布、卡片、阅读层
92
+ index.js 宿主侧空实现(这个插件只在客户端做事)
93
+ cordis.patch.yml 向 profile 插入一行 dsh-explore
94
+ locale/zh.json 中文展示名与描述
95
+ locale/en.json 英文展示名与描述
96
+ icon.svg 插件图标
97
+ assets/hero.svg README 头图(一条线分出多条路径)
98
+ test/render-smoke.cjs 渲染冒烟:假 React 真渲染整个视图,断言中英两套文案
99
+ test/canvas-visibility.cjs 可见性回归:在跑/等你节点必须被布局并画出,等待态文案与投影白名单
100
+ test/session-rebind.cjs 重新绑定:换 eventSource 后重订阅、空窗口不剪枝、冷会话要 open
101
+ test/theme-tokens.cjs 主题守卫:色值不写死、关键 token 必须存在、主按钮用反相前景
102
+ test/motion.cjs 动效:镜头插值、手势中断、导航替换、减少动态效果与清理
103
+ test/wheel-scroll.cjs 滚轮归属:内层能滚就滚,滚到头也不缩放画布
104
+ test/live-clock.cjs 运行中的卡片按墙钟计时,且全插件只有一个定时器
105
+ test/reader-dialog.cjs 阅读层是原生 modal:不再手写焦点陷阱,背景滚动被隔离
106
+ test/card-display.cjs 卡片信息量三档、卡片不再就地展开、阅读层宽度与几何
107
+ test/branch-sessions.cjs 分支会话归档策略:只收已完成的分支、可整体切换、fork 前临时解档
108
+ test/branch-archive-flow.cjs 归档流程端到端:回合结束后才归档、双向切换、墓碑不误放
109
+
110
+ test/markdown-table.cjs GFM 表格:对齐、转义竖线、横向滚动容器
111
+ test/markdown.cjs 受支持的 Markdown 全集,以及刻意不支持的那些
112
+ test/layout-direction.cjs 双向布局、不等高节点与折叠分支
113
+ test/host-overlay.cjs 宿主覆盖层、区域测量、阅读层与回退
114
+ test/locale-parity.cjs 八套语言表:键集合一致、{占位符} 对齐、不串字符集
115
+ test/reasoning.cjs 思考过程:实时尾巴、阅读层两面、无思考不显示、重试清空、封顶与真实截断计数
116
+ test/card-reading.cjs 卡片高度不随流式变化、唯一放大入口、阅读层的两面
117
+ test/card-attachments.cjs 提示里的附图:引用投影并落盘、卡片缩略图、纯图片提示也有卡
118
+ test/reasoning-persist.cjs 思考不落盘、重开从日志里回来、父子连线不丢
119
+ test/real-log.cjs 真实日志端到端检查(可选,吃一个 session.v4.jsonl.zstd)
120
+ docs/design.md 设计文档:数据模型、取舍、已知缺口
121
+ docs/releasing.md CI、Release Please 与 npm 发布
122
+ .github/workflows/ CI、Release Please 与手动的 npm 发布工作流
123
+ ```
124
+
125
+ ## 实现要点
126
+
127
+ 整个视图就是一个客户端插件;完整设计(数据模型、取舍、已知缺口)见 [docs/design.md](docs/design.md)。
128
+
129
+ - **注册点**:`conversation.view`,`id: tree`、`order: 5`、`label` 是一个 thunk(每次投影重新求值),与 Chat / Trajectory 并列。
130
+ - **界面文案跟随宿主语言**:所有可见文本都是 `dsh-explore` 命名空间下的键,通过客户端 locale 服务查表;切换语言时页签标题和整个视图一起切换。没有 locale 插件的 profile 会退回内置的中英表(按 `document.documentElement.lang` 选择)。
131
+ - **节点是日志的投影**:读取会话的 `entries`(持久事件 + 暂态 `assistant/live-chunk`),把一个 turn 投影成一张卡片;不额外写记录,所以在 Chat 里继续聊,树上就会自然长节点。
132
+ - **等待态没有专门事件**:宿主里 `ask_user_question` 与审批都只是「工具还没返回」——等回答期间不发 `turn/end`,`running` 也保持 `true`。插件用 `tool/call` 的 `ask_user_question`(`callId` 在 `tool/result` 里结清)和 `approval/asked → approval/decided` 算出「在等你」,把卡片从「正在调用工具」改成「等你回答 / 等你授权」。`user/message` 的 `source.kind` 只有 `user` 与 `user-question-reply` 两种,投影两端都认。
133
+ - **思考过程已经在事件窗口里**:模型把思考写进 `reasoning` 内容块——实时是暂态 `assistant/live-chunk` 上的 `reasoning-delta`,落定后是持久 `assistant/message` 里的 `{ type: 'reasoning', text }`。两者都原样到达插件,所以一次投影同时覆盖「正在想」和「想完了」:在跑时卡片显示最新一行做「思考尾巴」,落定后收进可展开的「思考过程」(折叠时仍写出最后一段,并在被截断时说明)。没有思考的模型不渲染这一节。重试会复用同一个 turn/step,所以先把上一次尝试的思考清掉。每张卡最多保留 12000 字,丢了字数按「每个块送达过的字节 − 保留长度」算出来,而不是累加计数器——同一个块会被裁不止一次。思考**不写进 `localStorage` 快照**:它能从日志重建,而快照里还放着重建不出来的父子连线。
134
+ - **附图是内容块,不是文字**:`user/message` 的 `content` 是一个块数组,文字只是其中一种,附图是另一种——`{ type: 'image', attachment: { attachmentId, mediaType, width, height, bytes, name } }` 与文字并排,所以 `textOf` 永远看不到它。投影按内容顺序保留这些引用,只带图片的提示也算一个真问题,并且引用跟着节点一起落盘:一条引用几百字节,图片本身留在宿主那边。渲染时按节点所属会话向宿主的受权读取器要 URL——先 `peekImageUrl`(重开的卡片因此不会先闪一下空白),没缓存再 `imageUrl`。这个服务是防御式读取的,也没有进插件的 `inject` 列表:宿主没有它时视图照常加载,只是没有缩略图。
135
+ - **正在跑的路径不折叠**:布局只走「未折叠」的节点,被折叠的节点连位置都没有、根本不会被画。所以通往「正在跑 / 在等你」节点的祖先路径一律不套用默认折叠;节点进入运行态时还会把路径展开并持久化,停在等用户时再把画布移过去。工具条上的运行计数与「在等你」计数都是跳转按钮。
136
+ - **会话会被重新绑定**:离开对话后宿主会释放它的引用,引用归零时 scope 被回收、`Session` 实例连同事件窗口一起丢掉;再进来时 `materializeScope` 会造一个新的 `eventSource`,窗口从空开始。所以订阅跟着 `eventSource` 换(旧的自动退订)、空窗口不当作「会话是空的」去剪枝、冷会话主动 `open()` 一次——否则直接在「无限探索」页签上切回来会得到一张空画布,而先点「回对话」再切回来又正常。`test/session-rebind.cjs` 守住这条。
137
+ - **分叉是真实会话**:`ctx.sessions.fork({ sessionId, atSeq })`,子会话天然继承到该回答为止的前缀上下文;每根枝会出现在会话列表里,插件会把它改名成 `⟂ 父问题 · 新问题` 便于辨认。
138
+ - **父子关系存在本地**:这一版 fork 不记录 `parentSession`,树形关系由插件在 `localStorage` 里维护,同时保存折叠状态、墓碑和布局方向。卡片高度在运行时测量。
139
+ - **主题**:颜色全部使用 `--dsw-alias-*` CSS 变量,浅色 / 深色主题自动跟随,不写死色值。主按钮的 `--dsw-alias-brand-primary` 在深浅主题下会反相(浅色近黑、深色近白),所以文字必须用配套的 `--dsw-alias-label-primary-foreground`,不能写死 `#fff`;行内代码用 `label-primary` 的 7% 着色(官方 inline-code token 在浅色下几乎是白的,放在白卡片上会看不见)。字体接组合后的 `--dsw-font-family` / `--ds-font-family-code`——DSH 已把用户字体和内置默认栈拼在一起,直接读组合 token 才能保住字形回退。`test/theme-tokens.cjs` 守住这些规则。
140
+
141
+ ## 开发
142
+
143
+ ```bash
144
+ npm test # 下面每一条一起跑(package.json 里的 scripts.test)
145
+
146
+ node --check client.js # 语法
147
+ node test/render-smoke.cjs # 渲染冒烟:把整个视图真渲染一遍,并断言中英两套文案
148
+ node test/canvas-visibility.cjs # 可见性回归:在跑/等你的节点必须被画出来,等待态文案与投影白名单
149
+ node test/session-rebind.cjs # 重新打开会话:scope 重建后换订阅、空窗口不剪枝、冷会话要 open
150
+ node test/theme-tokens.cjs # 主题守卫:色值不写死、token 必须存在、主按钮用反相前景 token
151
+ node test/motion.cjs # 动效:画布移动、手势中断、导航替换、减少动态效果与清理
152
+ node test/wheel-scroll.cjs # 滚轮归属:思考框能滚就滚,滚到头也不缩放画布
153
+ node test/live-clock.cjs # 耗时按墙钟每秒走,事件之间也不停;只有一个定时器
154
+ node test/reader-dialog.cjs # 阅读层用原生 <dialog>:showModal、close 回灌、背景滚动隔离
155
+ node test/card-display.cjs # 卡片信息量三档、无就地展开、阅读层标准宽/较宽与重排几何
156
+ node test/card-reading.cjs # 卡片高度不随流式变化、唯一放大入口、阅读层的两面
157
+ node test/card-attachments.cjs # 附图:引用进投影并落盘、卡片缩略图、纯图片提示也有卡片
158
+ node test/branch-sessions.cjs # 分支会话:只归档已完成的分支、可整体切换、fork 前临时解档
159
+ node test/branch-archive-flow.cjs # 归档流程端到端:回合结束才归档、双向切换、墓碑不误放
160
+ node test/markdown-table.cjs # 回答里的 GFM 表格
161
+ node test/markdown.cjs # 渲染器支持的每一种 Markdown 语法
162
+ node test/layout-direction.cjs # 双向布局、不等高节点和折叠分支
163
+ node test/host-overlay.cjs # 宿主覆盖层、区域测量、阅读层与回退
164
+ node test/locale-parity.cjs # 八套语言表的键、占位符与字符集
165
+ node test/reasoning.cjs # 思考过程:实时思考行、阅读层两面、无思考不显示、重试清空、封顶与真实截断计数
166
+ node test/reasoning-persist.cjs # 快照策略:思考不落盘,重开从日志里回来,父子连线不丢
167
+ ```
168
+
169
+ `node test/real-log.cjs <一个 session.v4.jsonl.zstd>` 可以拿真实日志跑一遍全链路,属于可选检查,不在 `npm test` 里。
170
+
171
+ `client.js` 是客户端插件(`window.__ModuleLoader__.load` 的惰性工厂),改完客户端热更新立即生效。注意样式表在每次 `apply()` 都会重写同一个 `<style>` 节点——如果只在节点已存在时跳过,热更新后的新规则永远不会生效。
172
+
173
+ ## CI 与发版
174
+
175
+ 向 `main` 提 PR 时,`.github/workflows/ci.yml` 在 Ubuntu / Windows × Node.js 22 / 24 上执行 `node --check index.js`、`npm test`、`npm pack --dry-run`。没有安装步骤——插件和测试都没有 npm 依赖,仓库里也没有 lockfile。
176
+
177
+ 发版走 Google Release Please,版本由 Conventional Commits 决定:它创建或更新一条发版 PR(改 `package.json`、manifest 和 `CHANGELOG.md`);合并后发版 job 在发版 commit 上跑完整矩阵,`npm pack` 出 `tanzz-dsh-explore-<version>.tgz`,附到 GitHub Release 上再公开,tag 由 GitHub 生成为 `v<version>`,同一 commit 还会带 provenance 发布到 npm。`@tanzz/dsh-explore@0.1.0` 是已发布的基线版本,之后每次发版都由这个工作流自动发布。
178
+
179
+ 首次启用(Actions 权限、可选的 `RELEASE_PLEASE_TOKEN`、npm Trusted Publishing)见 [CI 与自动发版说明](docs/releasing.md)。
180
+
181
+ ## 参与贡献
182
+
183
+ 见 [CONTRIBUTING.md](CONTRIBUTING.md)。提交信息和 PR 标题遵循 [Conventional Commits](https://www.conventionalcommits.org/)——Release Please 靠它算下一个版本;缺陷报告和功能请求走 issue 模板。
184
+
185
+ ## 安全
186
+
187
+ 见 [SECURITY.md](SECURITY.md)。安全问题请私下报告,不要开公开 issue。
188
+
189
+ ## 已知限制
190
+
191
+ - **树关系只在这台机器的这个浏览器里**:换浏览器、清站点数据或换 profile,树枝会平掉(每个会话自己那条链还在,但接不回同一棵树)。
192
+ - **树是会话级的**:没有「把几棵树摆在一起」的本子。
193
+ - **出错**:出错只体现在卡片状态上,不会自动跳过去;提问和审批则会(见「等你回答」)。
194
+ - **插件之外的 fork**:在 DSH 里、插件之外 fork 出来的会话识别不到,会被当成新树的根。
195
+
196
+ ## 许可证
197
+
198
+ [MIT](LICENSE) © 2026 tzzs
199
+
200
+ 参与本项目即表示同意遵守[行为准则](CODE_OF_CONDUCT.md)。