@kangyishuai/dsh-btw 0.2.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 +23 -6
- package/README.zh-CN.md +25 -6
- package/lib/client.js +899 -282
- package/lib/followup-queue.js +64 -0
- package/lib/format.js +73 -0
- package/lib/limits.js +2 -0
- package/lib/live.js +136 -0
- package/lib/markdown.js +695 -0
- package/lib/service.js +93 -20
- package/lib/subagent.js +11 -0
- package/lib/threads.js +91 -107
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,8 +15,13 @@ Unofficial plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/de
|
|
|
15
15
|
- **Cheap.** The fork reuses the parent conversation's prompt prefix, so the provider serves most of it from cache (measured: 57% on the first fork, 94% on a repeat). Cache writes are not billed.
|
|
16
16
|
- **Kept.** Answers are written to a per-session JSONL history so you can reopen the last one with a bare `/btw`.
|
|
17
17
|
- **Threads.** Follow up on a side question without losing the earlier exchange; the thread's history is replayed to the model each turn.
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
18
|
+
- **Streaming.** The drawer renders the answer as it is generated instead of waiting for the whole reply (the host buffers the child's text deltas; the panel reads them through `btw/live`).
|
|
19
|
+
- **Markdown.** Headings, lists, tables, quotes, fenced code and inline styles render properly. The promote draft keeps its Markdown source, so it renders correctly once you send it.
|
|
20
|
+
- **Readable numbers.** The cost badge adapts tokens to `K/M/B/T` and duration to `ms/s/m/h` (for example `new 12.3K · cached 988K · 32.5s`).
|
|
21
|
+
- **Promote to draft.** Turn the latest side question into a four-section Markdown draft (question / conclusion / key details / still unresolved) and **insert it into the composer — never send it**. You decide whether to send.
|
|
22
|
+
- **Native right sidebar.** The「旁问」button opens a tab in the DSH right sidebar: the conversation becomes narrower but is **never covered**.the sidebar's own collapse button (⌥⌘B) collapses the column and clicking the「旁问」button expands it again. Hosts without the sidebar service fall back to a right-edge overlay drawer.
|
|
23
|
+
- **Chat order.** Threads list oldest first with every turn expanded, the newest answer at the bottom, and the view follows the latest content.
|
|
24
|
+
- **Honest scope badge.** The drawer states how many side questions exist and reminds you that **the model can see the whole conversation**; a scope choice only narrows the instruction, it does not cut context.
|
|
20
25
|
|
|
21
26
|
## How it works
|
|
22
27
|
|
|
@@ -28,6 +33,8 @@ A third-party DSH plugin cannot reach a provider adapter through `ctx.llm` (ever
|
|
|
28
33
|
|
|
29
34
|
Follow-ups re-fork each turn and replay the thread's own Q&A into the prompt — a fork is single-turn, so keeping one child alive would degenerate into a full side session with its own lifecycle.
|
|
30
35
|
|
|
36
|
+
Live text never leaves the host process as raw history: an `llm/stream` observer keyed by the child session keeps at most 12k characters in memory, the panel polls `btw/live`, and the buffer is dropped when the run ends. The panel deliberately does not subscribe to the child session from the client: a forked child is seeded with the parent's completed transcript, so retaining it would download that whole history into the browser just to read the tail. Markdown is parsed on the host into a JSON block tree and the client only maps it to React elements — no HTML injection, no bundler, and no import of host UI packages.
|
|
37
|
+
|
|
31
38
|
Promote only **returns text** from the host and inserts it with the composer's `setDraft`; `submit` is never called. If the composer already has content the action is refused instead of overwriting what you were typing.
|
|
32
39
|
|
|
33
40
|
Scope is deliberately **advisory**: a fork inherits every completed turn of the parent, and a plugin cannot inherit a subset. The badge says so instead of pretending the context was trimmed.
|
|
@@ -49,8 +56,16 @@ Restart the DSH desktop app afterwards.
|
|
|
49
56
|
/btw --scope recent <q> # hint the answer to focus (session | recent | selection)
|
|
50
57
|
```
|
|
51
58
|
|
|
52
|
-
The
|
|
53
|
-
|
|
59
|
+
The panel opens from the「旁问」button left of the composer as a tab in the **native DSH right sidebar**:
|
|
60
|
+
the conversation becomes narrower but the panel never covers it. Use the sidebar's own collapse button (⌥⌘B) to collapse the column (the tab is
|
|
61
|
+
kept), and the「旁问」button to expand it again; close the tab with its own × or the panel's「关闭」button.
|
|
62
|
+
Hosts that do not load the sidebar service fall back to a right-edge overlay drawer that collapses to a
|
|
63
|
+
thin edge rail.
|
|
64
|
+
|
|
65
|
+
Threads are listed oldest first with every turn expanded, and the newest answer is at the bottom —
|
|
66
|
+
the view scrolls to the latest content when you open the drawer or when new content arrives. Each
|
|
67
|
+
answer renders Markdown; a long answer is clamped with「Show all」. The composer at the bottom starts
|
|
68
|
+
a new side question, while「Follow up」inside a thread opens that thread's own input.
|
|
54
69
|
|
|
55
70
|
## Configuration
|
|
56
71
|
|
|
@@ -82,9 +97,11 @@ The settings file is re-read on every use, so edits take effect without restarti
|
|
|
82
97
|
|
|
83
98
|
| Plugin | Verified on DSH |
|
|
84
99
|
| ------ | --------------- |
|
|
85
|
-
| 0.
|
|
100
|
+
| 0.4.0 | 0.2.2-rc.3 |
|
|
101
|
+
|
|
102
|
+
The underlying host seams (command dispatch while busy, fork cache reuse, `tools.guard`, `workspaceRegistry.archiveSession`) were verified on DSH 0.2.2-rc.3.
|
|
86
103
|
|
|
87
|
-
|
|
104
|
+
End-to-end status: the web smoke (temporary `DSH_HOME`, right-sidebar tab, collapse/expand, Markdown rendering) and a real `/btw` round trip pass. The desktop regression was updated for the tab shape and must be rerun after installing this version into the live desktop profile.
|
|
88
105
|
|
|
89
106
|
## License
|
|
90
107
|
|
package/README.zh-CN.md
CHANGED
|
@@ -15,8 +15,13 @@
|
|
|
15
15
|
- **便宜**:fork 复用主会话的提示前缀,服务端大部分走缓存(实测首次 fork 命中 57%,重复请求 94%),且不产生写缓存费用。
|
|
16
16
|
- **可留存**:答案写入按会话切分的 JSONL 历史,裸 `/btw` 可重新打开上一条。
|
|
17
17
|
- **可追问**:同一条旁问可以继续追问,线程内的问答每轮都会回放给模型。
|
|
18
|
-
-
|
|
19
|
-
-
|
|
18
|
+
- **流式输出**:抽屉里答案边生成边显示,不用等整段返回(host 缓冲子会话的 text-delta,面板通过 `btw/live` 读取)。
|
|
19
|
+
- **Markdown 渲染**:标题、列表、表格、引用、代码块与行内样式都会正常渲染;转正草稿保留 Markdown 源码,发送后由 DSH 正常渲染。
|
|
20
|
+
- **数字可读**:成本徽章的 token 数自适应 `K/M/B/T`,耗时自适应 `ms/s/m/h`(例如 `新增 12.3K · 命中缓存 988K · 32.5s`)。
|
|
21
|
+
- **一键转正**:把最近一条旁问整理成四节 **Markdown** 草稿(问题 / 结论 / 关键细节 / 仍未解决),**只插进输入框、绝不发送**,发不发由你决定。
|
|
22
|
+
- **原生右侧栏**:点「旁问」在 DSH 右侧边栏打开一个「旁问」tab,主对话变窄但**不被遮挡**;点右侧栏右上角的收起按钮(⌥⌘B)收起整栏,再点「旁问」展开。宿主没有右侧栏服务时回退到右侧浮层抽屉。
|
|
23
|
+
- **聊天式顺序**:线程从旧到新、每轮问答按时间展开,最新一条在最下面,打开或新内容到达时自动滚到底。
|
|
24
|
+
- **诚实的范围徽章**:抽屉会说明有多少条旁问,并提示**模型能看到完整会话**;范围档位只缩窄指令,不裁剪上下文。
|
|
20
25
|
|
|
21
26
|
## 怎么实现的
|
|
22
27
|
|
|
@@ -29,8 +34,14 @@
|
|
|
29
34
|
追问每轮**重新 fork** 并把线程内的问答回放进提示词 —— fork 是单轮语义,让一个子会话活着续聊会退化成
|
|
30
35
|
完整的 side session(更重、要管会话生命周期)。
|
|
31
36
|
|
|
37
|
+
流式文本只留在 host 进程内存里:`llm/stream` 观察器按子会话 id 截取 `text-delta`,最多保留 12k 字符,
|
|
38
|
+
面板轮询 `btw/live`,run 结束即释放。**刻意不**让 client 订阅子会话:fork 出来的子会话带着父会话全部已完成轮次
|
|
39
|
+
作为种子,client 一旦 retain 就会把整段历史拉到浏览器里,而旁问只需要最后几 KB 的增量。
|
|
40
|
+
Markdown 在 host 解析成 JSON 块树,client 只做 React 元素映射 —— 不注入 HTML、不引构建器、不加载宿主 UI 包。
|
|
41
|
+
|
|
32
42
|
转正只由 host **返回文本**,客户端用 composer 的 `setDraft` 插入,**从不调用 `submit`**;
|
|
33
|
-
|
|
43
|
+
输入框已有内容时直接拒绝,不覆盖你正在写的东西。草稿四节用 `##` 标题保留 Markdown 源码,
|
|
44
|
+
落进输入框是未渲染原文,发送后由 DSH 渲染。
|
|
34
45
|
|
|
35
46
|
范围是刻意做成**建议性**的:fork 会继承父会话全部已完成轮次,插件无法只继承一部分。
|
|
36
47
|
徽章如实说明这点,而不是假装上下文被裁剪过。
|
|
@@ -52,7 +63,13 @@ dsh plugin --profile desktop add @kangyishuai/dsh-btw
|
|
|
52
63
|
/btw --scope recent <问题> # 提示回答聚焦的范围(session | recent | selection)
|
|
53
64
|
```
|
|
54
65
|
|
|
55
|
-
|
|
66
|
+
面板点输入框左侧的「旁问」按钮打开:注册在 **DSH 原生右侧栏**(`sidebar.right.pane.tab`)里,
|
|
67
|
+
主对话会变窄但不被面板遮挡。点右侧栏右上角的收起按钮(⌥⌘B)收起整栏(tab 保留),再点「旁问」展开;tab 自带的 × 或
|
|
68
|
+
面板里的「关闭」按钮关闭 tab。宿主未加载右侧栏服务时,自动回退到右侧浮层抽屉(可收起成右边缘小条)。
|
|
69
|
+
|
|
70
|
+
线程从旧到新排列、每轮问答展开,最新一条在最下面;打开抽屉或有新内容时自动滚到底。
|
|
71
|
+
答案按 Markdown 渲染,超长时折叠为「展开全文」。底部输入框发起新旁问;
|
|
72
|
+
点线程里的「追问」会出现该线程自己的输入框。
|
|
56
73
|
|
|
57
74
|
## 配置
|
|
58
75
|
|
|
@@ -84,9 +101,11 @@ dsh plugin --profile desktop add @kangyishuai/dsh-btw
|
|
|
84
101
|
|
|
85
102
|
| 插件 | 已在 DSH 上验证 |
|
|
86
103
|
| ----- | --------------- |
|
|
87
|
-
| 0.
|
|
104
|
+
| 0.4.0 | 0.2.2-rc.3 |
|
|
105
|
+
|
|
106
|
+
底层宿主 seam(busy 时命令派发、fork 缓存复用、`tools.guard`、`workspaceRegistry.archiveSession`)已在 DSH 0.2.2-rc.3 上实测。
|
|
88
107
|
|
|
89
|
-
|
|
108
|
+
端到端情况:web 冒烟(临时 `DSH_HOME`,覆盖右侧栏 tab、收起/展开、Markdown 渲染)与真实模型往返都通过;桌面回归(`pnpm smoke:btw-desktop --require`)已更新为 tab 断言,需把本版本装进 desktop profile 后重跑。
|
|
90
109
|
|
|
91
110
|
## 许可证
|
|
92
111
|
|