dsh-reading-inbox 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.
package/README.en.md CHANGED
@@ -46,6 +46,8 @@ From npm:
46
46
  dsh plugin --profile web add dsh-reading-inbox
47
47
  ```
48
48
 
49
+ > pnpm's supply-chain policy waits before adopting a freshly published version. If an install right after a release picks the previous version, pin it: `dsh plugin --profile web add dsh-reading-inbox@0.2.1`.
50
+
49
51
  From GitHub:
50
52
 
51
53
  ```sh
@@ -105,7 +107,7 @@ Command output is shown in the UI only; the full article is not pushed into mode
105
107
  | `reading_list` | List by date, filtered by status/tag. |
106
108
  | `reading_read` | Read a Markdown slice by id; use `offset` / `nextOffset` for long articles and `hasMore` to know whether it is complete. |
107
109
  | `reading_update` | Change status or tags. Status: `unread` / `reading` / `read` / `archived`. |
108
- | `reading_highlight` | Create/list/update/delete highlights and notes. `action` is `create` / `list` / `update` / `delete`; `create` takes a `quote` from the article (or `startOffset`/`endOffset`), plus optional `note` and `color`. |
110
+ | `reading_highlight` | Create/list/update/delete highlights and notes. `action` is `create` / `list` / `update` / `delete`; `create` takes a `quote` from the article (plain text or Markdown; formatting is stripped, or pass `startOffset`/`endOffset`), plus optional `note` and `color`. |
109
111
 
110
112
  ## Configuration
111
113
 
@@ -175,7 +177,7 @@ See [VERIFY.md](VERIFY.md) for the end-to-end check inside a real DSH.
175
177
 
176
178
  ```sh
177
179
  npm run build:client # rebuild client/client.js with esbuild
178
- npm test # 27 tests: extraction, rendering, SSRF, DNS checks, annotation anchoring, store races, search, routes, client bundle
180
+ npm test # 30 tests: extraction, rendering, SSRF, DNS checks, annotation anchoring, store races, search, routes, client bundle
179
181
  npm run verify # end-to-end self-check
180
182
  ```
181
183
 
@@ -192,7 +194,7 @@ Layout:
192
194
 
193
195
  ## Limits and roadmap
194
196
 
195
- 0.2.0 is deliberately small:
197
+ 0.2.1 is deliberately small:
196
198
 
197
199
  - [ ] SPA / login / anti-bot pages may yield no article; add a Playwright fallback.
198
200
  - [ ] Images still point at remote URLs; download them into `clips/<id>/assets/` for a full offline archive.
package/README.md CHANGED
@@ -46,6 +46,8 @@ DSH 已经有 `web_fetch`、`read_url` 这类“读一次”的工具,但它
46
46
  dsh plugin --profile web add dsh-reading-inbox
47
47
  ```
48
48
 
49
+ > pnpm 的 supply-chain 策略会等新版本发布一段时间才默认采用它。刚发布后如果装到上一版,可显式指定版本:`dsh plugin --profile web add dsh-reading-inbox@0.2.1`。
50
+
49
51
  直接从 GitHub 安装:
50
52
 
51
53
  ```sh
@@ -105,7 +107,7 @@ dsh plugin --profile web add file:C:/path/to/dsh-reading-inbox
105
107
  | `reading_list` | 按时间列出,支持状态/标签过滤。 |
106
108
  | `reading_read` | 按 id 读取 Markdown 切片;用 `offset` / `nextOffset` 翻长文,`hasMore` 判断是否读完。 |
107
109
  | `reading_update` | 修改阅读状态或标签。状态:`unread` / `reading` / `read` / `archived`。 |
108
- | `reading_highlight` | 对文章做划线/批注:`action` 为 `create` / `list` / `update` / `delete`;`create` 传原文里的 `quote`(或 `startOffset`/`endOffset`),可选 `note` 和 `color`。 |
110
+ | `reading_highlight` | 对文章做划线/批注:`action` 为 `create` / `list` / `update` / `delete`;`create` 传原文里的 `quote`(纯文本或 Markdown,服务端会去掉格式;也可传 `startOffset`/`endOffset`),可选 `note` 和 `color`。 |
109
111
 
110
112
  ## 配置
111
113
 
@@ -175,7 +177,7 @@ npm run dev # http://127.0.0.1:4173/dsh-reading-inbox/
175
177
 
176
178
  ```sh
177
179
  npm run build:client # 重新构建 client/client.js(esbuild)
178
- npm test # 27 个测试:提取、渲染、SSRF、DNS 校验、批注锚定、存储竞态、检索、路由、客户端 bundle
180
+ npm test # 30 个测试:提取、渲染、SSRF、DNS 校验、批注锚定、存储竞态、检索、路由、客户端 bundle
179
181
  npm run verify # 端到端自检
180
182
  ```
181
183
 
@@ -192,7 +194,7 @@ npm run verify # 端到端自检
192
194
 
193
195
  ## 限制与 Roadmap
194
196
 
195
- 当前版本是 0.2.0,刻意不做大而全:
197
+ 当前版本是 0.2.1,刻意不做大而全:
196
198
 
197
199
  - [ ] SPA / 登录页 / 反爬页可能提取不到正文;下一步加 Playwright fallback。
198
200
  - [ ] 图片仍引用远程地址;下一步下载到 `clips/<id>/assets/` 做完整离线存档。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-reading-inbox",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "DeepSeek Harness 的阅读收件箱:网页剪藏、Markdown 存档、划线批注、标签、全文检索与 Agent 工具。",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -9,6 +9,28 @@ export function normalizeQuote(value) {
9
9
  return String(value ?? '').trim().slice(0, MAX_QUOTE_CHARS)
10
10
  }
11
11
 
12
+ /**
13
+ * Agent tools read Markdown, not rendered text. If a model quotes a passage
14
+ * with **bold**, a [link](url), inline code, or a list marker, the exact quote
15
+ * will not exist in the article's rendered text. This produces a plain-text
16
+ * fallback that still matches the visible sentence.
17
+ */
18
+ export function plainQuote(value) {
19
+ return String(value ?? '')
20
+ .replace(/!\[([^\]]*)\]\([^)]*\)/g, '$1')
21
+ .replace(/\[([^\]]+)\]\([^)]*\)/g, '$1')
22
+ .replace(/`+([^`]+)`+/g, '$1')
23
+ .replace(/\*\*([^*]+)\*\*/g, '$1')
24
+ .replace(/__([^_]+)__/g, '$1')
25
+ .replace(/~~([^~]+)~~/g, '$1')
26
+ .replace(/\*([^*\n]+)\*/g, '$1')
27
+ .replace(/_([^_\n]+)_/g, '$1')
28
+ .replace(/<[^>]+>/g, '')
29
+ .replace(/^\s{0,3}(?:#{1,6}\s+|>\s?|(?:[-*+]|\d+\.)\s+)/gm, '')
30
+ .trim()
31
+ .slice(0, MAX_QUOTE_CHARS)
32
+ }
33
+
12
34
  export function normalizeNote(value) {
13
35
  return String(value ?? '').trim().slice(0, MAX_NOTE_CHARS)
14
36
  }
@@ -160,14 +182,30 @@ export function buildAnnotationAnchor(text, input = {}) {
160
182
  } else if (validRange(hintStart, hintEnd, chars.length) && chars.slice(hintStart, hintEnd).join('') === quote) {
161
183
  resolved = { start: hintStart, end: hintEnd, quote }
162
184
  } else {
163
- const match = chooseOccurrence(chars, String(text), quote, {
164
- quote,
165
- prefix: input.prefix,
166
- suffix: input.suffix,
167
- startOffset: hintStart,
168
- })
185
+ const attempts = [quote, plainQuote(quote)]
186
+ .filter((value, index, values) => value !== '' && values.indexOf(value) === index)
187
+ let match = null
188
+ let matchedQuote = quote
189
+ for (const attempt of attempts) {
190
+ if (validRange(hintStart, hintEnd, chars.length) && chars.slice(hintStart, hintEnd).join('') === attempt) {
191
+ match = { start: hintStart, end: hintEnd }
192
+ matchedQuote = attempt
193
+ break
194
+ }
195
+ const found = chooseOccurrence(chars, String(text), attempt, {
196
+ quote: attempt,
197
+ prefix: input.prefix,
198
+ suffix: input.suffix,
199
+ startOffset: hintStart,
200
+ })
201
+ if (found !== null) {
202
+ match = found
203
+ matchedQuote = attempt
204
+ break
205
+ }
206
+ }
169
207
  if (match === null) throw new Error('找不到引文;文章可能已更新')
170
- resolved = { start: match.start, end: match.end, quote }
208
+ resolved = { start: match.start, end: match.end, quote: matchedQuote }
171
209
  }
172
210
 
173
211
  const around = contextOf(chars, resolved.start, resolved.end)
package/src/tools.js CHANGED
@@ -338,7 +338,8 @@ export function registerTools(ctx, { inbox }) {
338
338
  name: 'reading_highlight',
339
339
  description:
340
340
  'Create, list, update, or delete highlights/annotations on a clipped article. ' +
341
- 'For create, pass a quote copied from the article (or startOffset/endOffset); optional note and color. ' +
341
+ 'For create, pass a quote copied from the article (plain text or Markdown; formatting is stripped if needed), ' +
342
+ 'or startOffset/endOffset; optional note and color. ' +
342
343
  'For list, omit quote. For update/delete, pass annotationId. ' +
343
344
  'Use this when the user asks to highlight, mark, annotate, or review key passages.',
344
345
  parameters: {