dsh-quote-shot 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +15 -16
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -46,12 +46,12 @@ node install.mjs # 链接进 profile 并写入 dsh.profile.bundles
46
46
  ## 引用:怎么用
47
47
 
48
48
  1. 在助手消息下方点引号图标
49
- 2. 输入框上方出现一张 **引用卡片**(一行预览 + ×)
50
- 3. 正常写问题并发送 —— **卡片随后自动收起**
49
+ 2. 输入框里出现一枚 chip(`引用 · 被引用内容的开头`)
50
+ 3. 写你的问题并发送
51
51
 
52
- **两种粒度**:先选中一段文字再点 → 只引用那段;直接点 → 引用整条消息。
52
+ **引用的是整条消息**,没有「只引用选中片段」这种模式。
53
53
 
54
- **取消**:点卡片右侧的 × 只移除卡片。**注入发生在点击那一刻,撤不回**(DSH 会话是 append-only)。详见「已知边界」。
54
+ **取消**:点 chip 右侧的 × 就删掉了,输入框恢复原样。点引用按钮时**没有往会话里写任何东西**,所以这是真正的撤回,不是视觉上的隐藏。
55
55
 
56
56
  ---
57
57
 
@@ -100,14 +100,13 @@ chip 用 DSH 原生的 `inputTriggers.registerSource` 注册。**DSH 的输入
100
100
  ### 链路
101
101
 
102
102
  ```
103
- 点图标 → 读消息正文(DOM)
104
- → POST /quote-shot/inject { sessionId, text }
105
- → Host: ctx.agents.get(sessionId).inject({ role:'user', content, source:{form:'notice', summary} })
106
- → 注入一条折叠的上下文行(UI 显示 summary,模型读 content)
107
- → 前端添加卡片;发送后清空
103
+ 点图标 → 读消息正文(DOM,只用于 chip 的 label)
104
+ → 写入草稿:标记文本 + 一枚 chip(offset 0)
105
+ → 发送时 chip 序列化回同一行标记
106
+ → 模型调 quote_read 取全文
108
107
  ```
109
108
 
110
- `source.summary` 是卡片上那行预览,`content.text` 才是模型读到的全文 —— 两者分离,输入框全程干净。
109
+ `label` 是输入框里显示的那行摘要,`serialize` 输出的才是模型读到的内容 —— 两者分离,所以外观可以换而语义不动。
111
110
 
112
111
  ### 三个必须知道的实现细节
113
112
 
@@ -234,7 +233,7 @@ const text = (rendered === undefined || rendered === null || rendered.length ===
234
233
 
235
234
  | 文件 | 作用 |
236
235
  |---|---|
237
- | `index.js` | Host:注入路由 + 客户端日志路由 + `quote_read` 工具 |
236
+ | `index.js` | Host:`quote_read` 工具 + 消息文本路由 + 客户端日志路由(旧的注入路由保留但不再调用) |
238
237
  | `session-reader.js` | 从会话日志按 message id 取全文(多帧 zstd + 索引缓存) |
239
238
  | `client.js` | 浏览器:引用按钮、卡片、DOM 提取、发送检测 |
240
239
  | `test.mjs` | 离线单测(格式化、DOM 提取、注入调用、slot 注册) |
@@ -293,15 +292,15 @@ node install.mjs # 安装 / 刷新
293
292
  ## 引用:可撤回模式(当前默认,已实测通过)
294
293
 
295
294
  ```
296
- 点引用 → 读文本(仅卡片预览)→ 草稿插入 [引用消息 <id>——请先调用 quote_read 读取全文,再回答]
297
- 点 × → 从草稿删掉标记 → 真正撤回
295
+ 点引用 → 读文本(用于 chip 标签)→ 草稿写入 chip(底层是那行标记)
296
+ 点 × → 从草稿删掉 chip → 真正撤回
298
297
  发送 → 标记随消息带出 → 模型调 quote_read 取全文
299
298
  ```
300
299
 
301
300
  - ✅ **可撤回**:发送前会话从未被写过
302
301
  - ✅ **省 context**:消息里只有一行标记,不是几百字全文
303
- - ✅ **卡片有内容**:预览从 DOM 读,不需要注入
304
- - ⚠️ **代价**:草稿里会多一行标记(DSH 没有 before-send 钩子,标记必须点击时就位)
302
+ - ✅ **卡片有内容**:预览从 DOM 读,不依赖注入
303
+ - ⚠️ **代价**:草稿里会多一枚 chip(底层是那行标记)。DSH 没有 before-send 钩子,标记必须点击时就位。
305
304
 
306
305
  ### ⚠️ 标记必须带祈使句(这条是血的教训)
307
306
 
@@ -374,7 +373,7 @@ node install.mjs # 安装 / 刷新
374
373
 
375
374
  ## 已知边界
376
375
 
377
- - **草稿多一行标记**:`[引用消息 xxx]` 会出现在输入框里,发送后成为消息正文的一部分。
376
+ - **草稿里多一枚 chip**:输入框显示「引用 · 正文开头」,底层是 `[引用消息 xxx]`,发送后成为消息正文的一部分。
378
377
  - **模型可能不调工具**:见上,引用可能被忽略。
379
378
  - **极冷的会话读不到**:定位覆盖点击时上报的会话、存活会话、最近 25 个日志;更早且未在窗口内的会话会 `not-found`。
380
379
  - **抓取的是「当时的 DOM」**:卡片预览是点击瞬间的快照。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-quote-shot",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Quote a whole DSH message by reference: the composer carries only a message id, and the model reads the full text on demand through a quote_read tool instead of pasting it into the prompt.",
5
5
  "type": "module",
6
6
  "main": "index.js",