deep-read-summarize 0.3.7 → 0.3.10
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/CHANGELOG.md +96 -1
- package/README.en.md +14 -9
- package/README.md +15 -10
- package/cordis.patch.yml +14 -7
- package/docs/RELEASE.md +68 -8
- package/index.js +60 -6
- package/package.json +4 -3
- package/parsers/book.js +1 -1
- package/parsers/video.js +54 -18
- package/schemas/index.js +9 -2
- package/scripts/transcribe.js +376 -0
- package/skills/deep-read-summarize/SKILL.md +11 -9
- package/tests/index.test.js +377 -1
- package/tests/run-tests.js +7 -3
- package/workflow.js +89 -76
- package/scripts/transcribe.ps1 +0 -68
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,101 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
5
5
|
|
|
6
|
+
## [0.3.10] — 2026-09-24
|
|
7
|
+
|
|
8
|
+
对**已发布的 0.3.9** 做的一轮审计修复。审计对象是 **npm 上那份字节**(不是工作区):先确认 29 个文件与 tag `v0.3.9` **逐字节一致**,再在解包目录里跑该包自带的门禁(lint / security / 35 fixture / 38 node:test 全绿),然后逐项找问题。
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **uv 的 CPython 镜像已失效,会让「首次安装」的机器彻底装不上**(P1;继承自 0.3.6 的 PowerShell 脚本,不是 0.3.9 新引入)。镜像写死 `ghproxy.com`,而它现在 **301 到 `ghfast.top` 并丢掉路径** —— 返回的是 HTML 而不是资产,uv 拿到 HTML 报 `Invalid gzip header`,而且**不会自己回退 GitHub**。真机验证:`uv venv --python 3.11` 带该镜像 → 退出码 2 失败;不带镜像(对照)→ 成功。踩到的恰好是**本机没有任何 Python 3.12 的新用户**。
|
|
13
|
+
- 现在:默认镜像换成实测可用的继任服务,**失败自动改用直连 GitHub 重试一次**(并清理失败留下的半个 venv);另可用环境变量 `DRS_UV_PYTHON_MIRROR` 覆盖(空字符串 = 完全不用镜像)。
|
|
14
|
+
- **转写结果为 0 字节时仍返回成功**(P2)。纯静音 / 纯 BGM 视频会被 VAD 全部滤掉,脚本却以退出码 0 结束、只留一条 stderr 警告,并且留下一个 0 字节文件;而调用方按「输出文件非空」判断完成、提示词里又有一条「日志出现 DONE」——**空逐字稿会被当成转写成功**,再拿去做精读。现在:删除空文件、以退出码 **3** 结束,并明确要求按降级处理。
|
|
15
|
+
- **`--audio` 指向目录时报错晦涩**(P3):此前 `existsSync` 直接放行,最后抛出 python 的 `PermissionError: [Errno 13] Permission denied`。现在先校验是否为普通文件,直接报「不是文件(是不是给了目录?)」。
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- **`docs/RELEASE.md` 两处与实况不符**(P2,会随包发给用户):
|
|
20
|
+
- 「当前版本速览」停留在 v0.1.x / v0.2.x + 计划中的 v1.0.0,**完全没有 0.3.x**;现在补全,并加了一道断言守着它(发版忘了更新会让 `npm run test:node` 变红)。
|
|
21
|
+
- 发布流程教的是「建 Release → 触发 publish.yml」+「用 `npm view` 验证」—— **恰好就是实测踩到的两个坑**。现在改为:手动 dispatch 为主路径;Release 事件投递不稳、只当记录;并写明判据(看日志的 `+ 包名@版本` 与 provenance;registry 有 1–2 分钟延迟,当场查必然 E404;dry-run 全绿不算发布成功)。
|
|
22
|
+
- `README.md` / `README.en.md`:选项示例补上 `maxRetries`(SKILL.md 与代码本来就有它);转写工具链一节补上「镜像可覆盖 + 失败自动回退直连」。
|
|
23
|
+
- `parsers/video.js` 提示词:转写步骤明确「脚本以非 0 退出也算失败」,包含「结果为空」的情况。
|
|
24
|
+
|
|
25
|
+
### Compatibility
|
|
26
|
+
|
|
27
|
+
- 无破坏性变更,默认值与既有行为不变(`device` 仍默认 `cpu`、`transcribe` 仍默认 `true`)。
|
|
28
|
+
- 唯一可感知的变化:**纯静音音频现在会「失败」而不是「成功返回空文本」** —— 这正是修复目的,调用方本就应该走降级路径。
|
|
29
|
+
- `DRS_UV_PYTHON_MIRROR` 是新增的可选环境变量;不设时行为与 0.3.9 相同(只是默认镜像换成了还活着的那个)。
|
|
30
|
+
|
|
31
|
+
## [0.3.9] — 2026-09-22
|
|
32
|
+
|
|
33
|
+
**macOS / Linux 支持**。这一版补上最后一块 Windows-only 的拼图:此前「无字幕视频自动转写」依赖 `scripts/transcribe.ps1`(PowerShell),SKILL.md 里明确写着「**目前仅在 Windows 可用**」;现在换成跨平台的 Node 脚本,三平台同一份实现、同一条命令。
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- **`scripts/transcribe.js` 取代 `scripts/transcribe.ps1`**:跨平台转写自举脚本(Windows / macOS / Linux)。平台差异只集中在四个纯函数里(`cacheRoot` / `venvPython` / `uvInstallHint` / `findUv`),它们都接受注入的 `platform/env/home`——因此**任意 OS 上都能跑全平台矩阵单测**,不必依赖 macOS 机器。
|
|
38
|
+
- 缓存目录:Windows `%LOCALAPPDATA%\deep-read-summarize`、macOS `~/Library/Caches/deep-read-summarize`、Linux `$XDG_CACHE_HOME/deep-read-summarize`
|
|
39
|
+
- uv 探测:先扫 PATH,再回退 `~/.local/bin`、`/opt/homebrew/bin`、`/usr/local/bin`、`~/.cargo/bin`(macOS 从图形界面启动时不继承 shell PATH,这一步是必需的);找不到时按平台给出安装命令(winget / brew / curl 安装器)
|
|
40
|
+
- `--self-check`:只打印解析出的路径,不安装、不下载、不联网——CI 三平台用它做冒烟
|
|
41
|
+
- **`options.device` 选项**(默认 `cpu`,可选 `auto`/`cuda`):从 options → workflow 脚本 → 解析器 → 命令行全程打通(与 `whisperModel` / `language` 同一条路径),不是写死在提示词里。`auto`/`cuda` 需自备 CUDA 运行库,失败自动回退 CPU。
|
|
42
|
+
- **CI 新增 `cross-platform` 作业**:在 ubuntu / macos / windows 三个 runner 上跑 lint + `--self-check`,真正在 macOS 上执行一遍平台分支。
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- **`device='auto'` 在「有 NVIDIA 显卡但没装 CUDA 运行库」的机器上必崩(真机复现)**:ctranslate2 只要探测到显卡(`get_cuda_device_count() == 1`)就会在 `auto` 下选 CUDA,随后在推理时抛 `Library cublas64_12.dll is not found or cannot be loaded`。这是 0.3.6 起就潜伏在 `transcribe.ps1` 里的问题(本机 RTX 3050 复现)。现在默认 `device=cpu`(与 README 承诺的「CPU 友好、零额外依赖」一致);设 `options.device: "auto"` 时,失败也会**自动回退 CPU 并打印原因**。
|
|
47
|
+
- **转写中途失败会留下半截 `transcript.txt`**:调用方(提示词第 ④ 步)是按「输出文件非空且稳定」判断转写完成的,半截文件会被**误判成成功**。现在先在内存里收集全部分段,成功后才落盘。
|
|
48
|
+
- **`parsers/video.js` 提示词里的 PowerShell 路径少了分隔符**:`$env:USERPROFILE\.dsh` 写在 JS 字符串里,`\.` 被当成未知转义退化成 `.`,实际发出去的提示词是 `$env:USERPROFILE.dsh`。改用正斜杠(PowerShell 同样接受)。
|
|
49
|
+
- **`parsers/book.js` 让代理用 `pwsh` 调 pdftotext**(第二轮全仓复查才发现,第一轮只盯着转写链路):macOS 默认没有 PowerShell,**书籍/PDF 这条路在 macOS 上会直接卡住**。现在改成平台中立的 pdftotext 说明,并给出三平台安装方式(macOS `brew install poppler` / Windows `winget install poppler` / Debian·Ubuntu `apt install poppler-utils`)。
|
|
50
|
+
- **`--out` 的父目录不存在时失败信息难以理解**:现在脚本自己先把父目录建好(`./.tmp` 这类调用方路径),不再让 python 抛一句难懂的 `No such file or directory`。
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- **`parsers/video.js` 提示词改为平台中立**:同时给出 Windows 与 macOS/Linux 的脚本定位命令(`Get-ChildItem … -Filter transcribe.js` / `find "$HOME/.dsh" -name transcribe.js`),yt-dlp 安装同时给出 `winget` 与 `brew`;转写命令三平台统一为 `node <脚本路径> --audio … --out … --device cpu --model … --language …`。
|
|
55
|
+
- 提示词**不能**按平台分支:它会被内联进 workflow 沙箱脚本,而沙箱不提供 `process`(`tests/run-tests.js` 有对应断言),所以两套写法都写出来、由执行代理按自己的系统选。
|
|
56
|
+
- 转写输出不再带结尾空格(改用 `' '.join(...)`)。
|
|
57
|
+
- 提示词里「转写执行」的 ①–⑥ 子步骤此前被模板编号成了一个独立的顶层步骤(`7. ① 先取音频…`,后续行反而没有编号),现在与标题合并为同一步,编号回到 `6. 转写执行(…):` + 未编号的 ①–⑥。
|
|
58
|
+
- `README.md` / `README.en.md` / `SKILL.md` 同步:删掉「仅 Windows 可用」,补上跨平台命令、平台缓存目录与 `options.device` 说明。
|
|
59
|
+
|
|
60
|
+
### Compatibility
|
|
61
|
+
|
|
62
|
+
- **Windows 用户零迁移成本**:缓存目录与 `transcribe.ps1` 逐字一致,**已下载的模型不会重下**(真机验证:复用既有 venv + 模型,未触发下载)。
|
|
63
|
+
- 唯一入口改名 `transcribe.ps1` → `transcribe.js`;提示词文本随之变化(脚本名、参数形式、`options.device`),依赖提示词逐字比对的 fork 需要同步。
|
|
64
|
+
- 转写默认从 `auto` 变为 `cpu`:原 `auto` 在无 CUDA 运行库的机器上本来就会崩,真正的 GPU 用户可显式传 `--device auto`。
|
|
65
|
+
|
|
66
|
+
## [0.3.8] — 2026-09-16
|
|
67
|
+
|
|
68
|
+
又一次「代码审查 + 真机复现」驱动的修复轮。这一轮的核心发现不是某一行写错了,而是**几处「文档承诺」与「代码实际行为」对不上**:选项算出来不用、schema 抄了两份各自漂移、配置文件里的键全是空转。所有 P0 都用 mock 掉 `agent/parallel/phase/log` 的方式**跑真实脚本复现过**,并各自补了回归测试。测试 35 → **62**(fixture 35 + node:test 27)。
|
|
69
|
+
|
|
70
|
+
### Fixed
|
|
71
|
+
|
|
72
|
+
- **frontmatter 注入:标题里带引号会产出坏 YAML(P0)**。`title: "《" + finalTitle + "》…"` 是裸拼,内容标题含 `"`(如 *The "Best" Method*)时 frontmatter 直接被截断,Obsidian / Dataview 全部解析失败。现在统一走 `yamlStr()`(JSON 字符串转义,是 YAML double-quoted 风格的子集),`title / aliases / author / year / type / url` 全部转义;标题里的换行/制表也一并折叠,不再污染 `.md` 文件名。
|
|
73
|
+
- **幂等命中分支会返回空笔记(P0)**。脚本里那段 `args._processedKeys` 早返回,命中时返回 `note: ""` + `filePath: ""`;而 SKILL.md 第 8 步要求主代理「把 `note` 写入 `filePath`」——命中即写出空文件。宿主实际上**从不注入 `args._processedKeys`**(0.1.x 全仓 0 命中),这段代码永远不会命中,一旦命中就是数据事故。整段删除。
|
|
74
|
+
- **分块计划不受 `maxChunks` 约束(P0)**。提示词里写着「块数不超过 N 块」,但脚本原样相信子代理返回的 `chunkPlan`:实测 `maxChunks: 4` 会起 **10 个子代理**——这正是 0.3.x 反复踩的「单次调用超时」的成因。现在按上限截断,并在收敛时记日志。
|
|
75
|
+
- **分块行号区间不校验(P0)**。倒置区间(`startLine: 900, endLine: 100`)会原样拼成 `limit=-799` 交给 `read`。现在丢弃倒置/越界的块,并按 `totalLines` 夹紧上界;全部无效时按可降级错误返回,不再空跑。
|
|
76
|
+
- **全非法字符的标题会写出隐藏文件**:`///` 之类清洗后为空 → `./output/.md`。现在兜底为 `未命名内容.md`。
|
|
77
|
+
- **`options.transcribe: false` 完全无效**。`parsers/video.js` 里 `wantTranscribe` 算完从未被使用,`true` 与 `false` 生成的提示词**逐字相同**,README/SKILL 却都承诺「false 则跳过转写」。现在提示词真的分流:禁用时明确禁止定位/运行 `transcribe.ps1`、禁止下载模型,直接走降级。
|
|
78
|
+
- **`options.whisperModel` / `options.language` 文档教用、代码没有**。README 写着「可用 `options.whisperModel` 调整」「纯英文视频可设 `language: "en"`」,但脚本既不读也不透传,转写命令里 `-Model small -Language zh` 是写死的。现在两个选项都从 options → 脚本 → 解析器 → 命令行全程打通,默认值保持 `small` / `zh`(对既有用户零行为变化)。
|
|
79
|
+
- **`kind` 会变成 `"auto"` 流进笔记**。`type: auto` 且子代理没回 `kind` 时,`frontmatter` 的 `type` 与 `tags` 会被写成 `auto`。现在 `auto` 只接受解析器表里真实存在的类型,否则退回实际使用的回退解析器。
|
|
80
|
+
|
|
81
|
+
### Changed
|
|
82
|
+
|
|
83
|
+
- **插件 config 不再是空转**。`apply(ctx, config)` 此前收了 config 从不读它,`cordis.patch.yml` 里列的 8 个键(`outputDir`/`tempDir`/`minWords`/…)全部无效。现在会做白名单校验(类型不符 → 告警并忽略,不会因为一个拼错的键把整个 profile 拖死),合并进技能里的 args 示例,成为该 profile 的默认值。`cordis.patch.yml` 的注释同步改写(含 `maxChunks` 6 → 4)。
|
|
84
|
+
- **schema 不再有两份真相**。脚本里那份手抄的 `fetchSchema` 已删除,改由 `workflow.js` 在构建自包含脚本时从 `schemas/index.js` **注入**;`kind` 的 `enum` 跟着解析器注册表走。此前手抄副本已经漂移(丢了 `enum`)。同时把 `chunkReadSchema` / `qualityChecklistSchema` **没有被 workflow 使用**这件事写进 `schemas/index.js` 头部——它们留给程序化调用方。
|
|
85
|
+
- **自定义解析器真正可用**。以前 `type` 白名单写死 `auto|book|paper|video|web`,且自包含脚本只内联这四个,`custom-parsers/` 里的**新类型**端到端不可达。现在内联的是注册表里的全部解析器,白名单与 schema 枚举都从注册表推导;同名覆盖照旧有效。
|
|
86
|
+
- **幂等从「脚本假装会做」改成「文档如实说不会做」**。脚本沙箱没有文件系统,写不了指纹记录——`lib/cache.js` 从 0.1.0 起就没被 workflow 调用过。现在 SKILL.md 第 2 步改为:由主代理在落盘前检查目标 `filePath` 是否已存在;程序化去重可用 `deep-read-summarize/lib/cache`(`package.json` 的 `exports` 补上了这个子路径,此前被 exports map 挡住根本 require 不到)。
|
|
87
|
+
- SKILL.md 新增第 9 步:`ok: false` 要说明卡在哪一步,`qualityPassed: false` / `failedChunks > 0` 必须在回复里点出来,不许拿半成品冒充成品。
|
|
88
|
+
- `prepublishOnly` 补跑 `node --test`(此前发布门禁只跑 fixture 测试,`tests/index.test.js` 不在门禁内)。
|
|
89
|
+
- npm 描述去掉 `idempotent cache`(工作流层确实没有这个能力)。
|
|
90
|
+
|
|
91
|
+
### Added
|
|
92
|
+
|
|
93
|
+
- **workflow 运行时回归测试(12 → 27 项 `node:test`)**:用 mock 掉 `agent/parallel/phase/log` 的方式跑**真实脚本**,逐条锁住本轮修的 P0/P1——分块收敛、区间夹紧、全无效计划降级、YAML 转义、隐藏文件名兜底、`kind` 兜底、幂等早返回已移除、`transcribe` 分流、`whisperModel`/`language` 透传、config 校验与透传、schema 单一真相、自定义类型端到端(含自定义解析器内联与枚举跟进)、未知类型仍然响亮报错、`lib/cache` 可达。
|
|
94
|
+
|
|
95
|
+
### Compatibility
|
|
96
|
+
|
|
97
|
+
- 对既有用户**无破坏性变更**:默认值全部保持不变(`maxChunks` 4、`transcribe` true、`whisperModel` small、`language` zh、`outputDir` `./output`)。
|
|
98
|
+
- 行为变化仅在于「以前被静默忽略的东西现在生效了」:超过 `maxChunks` 的计划会被截断(子代理数下降、耗时下降)、非法分块区间会被丢弃(此前会把负数 limit 传给 `read`)。
|
|
99
|
+
- 历史文档 `docs/RELEASE-v0.1.0.md` 里 v0.1.0 的「幂等缓存」描述保持原样(它是对当时意图的记录),实际能力以本节与 `schemas/index.js` 的说明为准。
|
|
100
|
+
|
|
6
101
|
## [0.3.7] — 2026-09-09
|
|
7
102
|
|
|
8
103
|
针对 **DSH 0.1.2-rc.1** 的一轮兼容性核查与打磨(对使用者无破坏性变更)。
|
|
@@ -167,4 +262,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
167
262
|
### Added
|
|
168
263
|
- Initial deep-reading pipeline (5 serial waves)
|
|
169
264
|
- Template prompts for books/papers/videos/web
|
|
170
|
-
- Obsidian note template with YAML frontmatter
|
|
265
|
+
- Obsidian note template with YAML frontmatter
|
package/README.en.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://github.com/PensiveFei/deep-read-summarize/blob/main/LICENSE)
|
|
4
4
|
[](https://github.com/PensiveFei/deep-read-summarize/releases)
|
|
5
5
|
[](https://github.com/PensiveFei/deep-read-summarize/actions/workflows/ci.yml)
|
|
6
|
-
[](https://www.npmjs.com/package/deep-read-summarize)
|
|
7
7
|
|
|
8
8
|
> **Disclaimer**: This is an **unofficial third-party tool**. It is not affiliated with, endorsed by, or sponsored by DeepSeek or the DeepSeek Harness project. "DeepSeek" and "DeepSeek Harness" are trademarks of their respective owners. This project only orchestrates the workflow tool available in your DSH environment; it does not redistribute any DeepSeek software.
|
|
9
9
|
|
|
@@ -37,7 +37,8 @@ Content is split into chunks, read in parallel by multiple sub-agents, then merg
|
|
|
37
37
|
|
|
38
38
|
- Books (PDF/EPUB/MOBI), papers (arXiv/PDF/HTML), videos (**subtitles first, auto-transcription when there are none** — produces a full transcript for deep reading), web pages
|
|
39
39
|
- Long content is chunked and read in parallel by sub-agents, then merged
|
|
40
|
-
-
|
|
40
|
+
- The fetch/chunk plan and the quality check are constrained by JSON Schema, so their output is stable and machine-readable
|
|
41
|
+
- Chunk count — and therefore sub-agent count — is enforced by `maxChunks` (a runaway plan blows the per-call time limit)
|
|
41
42
|
- Key citations must carry page/chapter/paragraph references to reduce fabrication
|
|
42
43
|
- Configuration errors abort immediately; a chunk that fails to parse is skipped and marked as a gap
|
|
43
44
|
- Output drops straight into Obsidian and works with Dataview
|
|
@@ -71,16 +72,16 @@ Three waves, roughly N+2 sub-agents in total, where N is the number of chunks.
|
|
|
71
72
|
parsers/ Parsers for each input type, dispatched by type
|
|
72
73
|
book.js Books: PDF/EPUB/MOBI text extraction, chapter chunking
|
|
73
74
|
paper.js Papers: arXiv/PDF/HTML structure detection
|
|
74
|
-
video.js Video: full transcript (subtitles first; auto-transcribe via scripts/transcribe.
|
|
75
|
+
video.js Video: full transcript (subtitles first; auto-transcribe via scripts/transcribe.js when none)
|
|
75
76
|
web.js Web pages: main-text extraction
|
|
76
77
|
index.js Registry: parser discovery and fallback
|
|
77
|
-
schemas/ JSON Schema for
|
|
78
|
-
scripts/ lint, security checks
|
|
78
|
+
schemas/ JSON Schema for the output contract (injected into the script by workflow.js - single source of truth)
|
|
79
|
+
scripts/ lint, security checks, cross-platform transcription bootstrap (transcribe.js)
|
|
79
80
|
tests/ fixture tests and validation scripts
|
|
80
81
|
workflow.js The workflow script itself (meta + script)
|
|
81
82
|
```
|
|
82
83
|
|
|
83
|
-
To change how an input type is handled, drop a parser with the same interface into `custom-parsers/`; a type with the same name overrides the built-in implementation. The interface has only three fields: `name`, `types`, `buildPrompt(input, opts)`.
|
|
84
|
+
To change how an input type is handled, drop a parser with the same interface into `custom-parsers/`; a type with the same name overrides the built-in implementation, and you can also add a brand-new type name (e.g. `podcast`) - every registered parser is inlined into the workflow script, and both the `type` whitelist and the schema's `kind` enum follow the registry. The interface has only three fields: `name`, `types`, `buildPrompt(input, opts)`.
|
|
84
85
|
|
|
85
86
|
---
|
|
86
87
|
|
|
@@ -101,7 +102,7 @@ deep-read-summarize is a DSH plugin installable via npm, the dsh.so ecosystem, o
|
|
|
101
102
|
npm install deep-read-summarize
|
|
102
103
|
|
|
103
104
|
# or local install (dsh profile directory)
|
|
104
|
-
pnpm add ./deep-read-summarize-0.3.
|
|
105
|
+
pnpm add ./deep-read-summarize-0.3.10.tgz
|
|
105
106
|
# then append to the dsh config's dsh.profile.bundles:
|
|
106
107
|
# - deep-read-summarize
|
|
107
108
|
# restart dsh web (POST /dsh-market/restart)
|
|
@@ -174,6 +175,10 @@ Pass this JSON to DSH's workflow tool:
|
|
|
174
175
|
"fastMode": false, // true skips sections 5-7, faster
|
|
175
176
|
"maxChunks": 4, // chunk limit, 1-12 (default lowered to control sub-agent count and time)
|
|
176
177
|
"transcribe": true, // video: auto local transcription (faster-whisper) when no subtitles; false skips it — see Video
|
|
178
|
+
"whisperModel": "small", // video ASR tier: small | base | medium
|
|
179
|
+
"language": "zh", // video ASR language: use "en" for English-only videos
|
|
180
|
+
"device": "cpu", // ASR device: cpu (default) | auto | cuda; auto/cuda needs a CUDA runtime and falls back to cpu
|
|
181
|
+
"maxRetries": 0, // quality-check retries (default 0 = no retry; retrying is noticeably slower)
|
|
177
182
|
"requireCitations": true, // whether key conclusions must carry citations
|
|
178
183
|
"includeTimestamps": false,
|
|
179
184
|
"outputDir": "./output", // note output directory (can point at your Obsidian vault)
|
|
@@ -200,12 +205,12 @@ Video text extraction is a **unified pipeline** (the old "three tiers" are gone)
|
|
|
200
205
|
> **⚠️ To preserve deep-reading quality, processing may take noticeably longer (a deliberate trade-off, not a hang)**: a **subtitle-less** video is transcribed first (roughly 0.5–2× the video length on CPU) before deep reading, so such videos are **much slower than subtitled videos**; in exchange you get a **full transcript + real deep reading**. **Subtitled** videos remain seconds-fast. Please do not mistake the slower transcription for a hang.
|
|
201
206
|
|
|
202
207
|
1. **Platform subtitles available** (Bilibili's official API AI subtitles / YouTube CC) → **use them directly** (= full text, fastest, zero dependencies).
|
|
203
|
-
2. **No public subtitles** → use the bundled transcription `scripts/transcribe.
|
|
208
|
+
2. **No public subtitles** → use the bundled transcription `scripts/transcribe.js` (faster-whisper small / int8 / VAD / Chinese) to get the full text.
|
|
204
209
|
3. **Neither works** → **degrade gracefully**: prompt the user to supply a transcript manually, or fall back to `desc` as background; **never block**.
|
|
205
210
|
|
|
206
211
|
`options.transcribe`: **default `true`** (auto-transcribe when no subtitles); set `false` to skip transcription (use subtitles/desc or degrade).
|
|
207
212
|
|
|
208
|
-
**Transcription toolchain (identical for you and the author)**: the script **bootstraps itself** — it uses `uv` to create a **Python 3.12** environment + **Tsinghua mirror** to install `faster-whisper`, downloads the model via `HF_ENDPOINT=https://hf-mirror.com` and **caches it for reuse**; faster-whisper bundles PyAV to decode audio, so **no separate ffmpeg** is needed; **versions are pinned** (Python 3.12 / faster-whisper / uv) so the author's environment matches yours.
|
|
213
|
+
**Transcription toolchain (identical for you and the author)**: the script **bootstraps itself** — it uses `uv` to create a **Python 3.12** environment + **Tsinghua mirror** to install `faster-whisper`, downloads the model via `HF_ENDPOINT=https://hf-mirror.com` and **caches it for reuse**; faster-whisper bundles PyAV to decode audio, so **no separate ffmpeg** is needed; **versions are pinned** (Python 3.12 / faster-whisper / uv) so the author's environment matches yours. The script is written in **Node**, so **Windows / macOS / Linux share one implementation and one command** (`node scripts/transcribe.js --audio <file> --out <txt>`). Transcription runs on **CPU** by default (`options.device`); GPU needs a CUDA runtime (cuBLAS/cuDNN), so `options.device: "auto"` is opt-in and falls back to CPU automatically. Cache location per platform: Windows `%LOCALAPPDATA%\deep-read-summarize`, macOS `~/Library/Caches/deep-read-summarize`, Linux `$XDG_CACHE_HOME/deep-read-summarize`. Python provisioning uses a mirror for speed and **falls back to a direct GitHub download when the mirror fails** (a dead mirror must not make the feature uninstallable); override it with the `DRS_UV_PYTHON_MIRROR` environment variable (empty string = never use a mirror).
|
|
209
214
|
|
|
210
215
|
> ⚠️ **The first transcription downloads the model first (small ≈ 484 MB, via hf-mirror, not GitHub) and may take a few minutes** — please be patient; **it downloads only once** on your machine, then every later transcription uses the cache and starts instantly. **Only subtitle-less videos trigger transcription** (subtitled videos use their subtitles directly — no trigger, no download).
|
|
211
216
|
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://github.com/PensiveFei/deep-read-summarize/blob/main/LICENSE)
|
|
4
4
|
[](https://github.com/PensiveFei/deep-read-summarize/releases)
|
|
5
5
|
[](https://github.com/PensiveFei/deep-read-summarize/actions/workflows/ci.yml)
|
|
6
|
-
[](https://www.npmjs.com/package/deep-read-summarize)
|
|
7
7
|
|
|
8
8
|
> **Disclaimer**: This is an **unofficial third-party tool**. It is not affiliated with, endorsed by, or sponsored by DeepSeek or the DeepSeek Harness project. "DeepSeek" and "DeepSeek Harness" are trademarks of their respective owners. This project only orchestrates the workflow tool available in your DSH environment; it does not redistribute any DeepSeek software.
|
|
9
9
|
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
|
|
38
38
|
- 书籍(PDF/EPUB/MOBI)、论文(arXiv/PDF/HTML)、视频(**字幕优先,无字幕自动转写**,出品完整逐字稿精读)、网页
|
|
39
39
|
- 长内容分块后由并行子代理精读,再合并
|
|
40
|
-
-
|
|
40
|
+
- 获取/分块与质量校验的输出受 JSON Schema 约束,结构稳定、下游可解析
|
|
41
|
+
- 分块计划与子代理数量受 `maxChunks` 强制约束(计划失控会顶穿单次调用时限)
|
|
41
42
|
- 关键引用必须标注页码/章节/段落,降低编造风险
|
|
42
43
|
- 配置错误直接报错终止;某块内容解析失败则跳过并标记缺口
|
|
43
44
|
- 输出可直接放进 Obsidian,配合 Dataview 使用
|
|
@@ -71,16 +72,16 @@ Obsidian 笔记
|
|
|
71
72
|
parsers/ 各输入类型的解析器,按类型分发
|
|
72
73
|
book.js 书籍:PDF/EPUB/MOBI 文本提取、章节分块
|
|
73
74
|
paper.js 论文:arXiv/PDF/HTML 结构识别
|
|
74
|
-
video.js 视频:完整逐字稿(字幕优先,无字幕自动转写,走 scripts/transcribe.
|
|
75
|
+
video.js 视频:完整逐字稿(字幕优先,无字幕自动转写,走 scripts/transcribe.js)
|
|
75
76
|
web.js 网页:正文提取
|
|
76
77
|
index.js 注册表:解析器发现与回退
|
|
77
|
-
schemas/
|
|
78
|
-
scripts/ lint
|
|
78
|
+
schemas/ 输出约束的 JSON Schema(波次1 由 workflow.js 注入脚本,单一真相)
|
|
79
|
+
scripts/ lint、安全检查、跨平台转写引导(transcribe.js)
|
|
79
80
|
tests/ fixture 测试与验证脚本
|
|
80
81
|
workflow.js workflow 脚本本体(meta + script)
|
|
81
82
|
```
|
|
82
83
|
|
|
83
|
-
想换某个输入类型的处理方式,在 `custom-parsers/`
|
|
84
|
+
想换某个输入类型的处理方式,在 `custom-parsers/` 放一个同接口的解析器即可,同名类型会覆盖内置实现;用新类型名(如 `podcast`)也可以——注册表里的解析器会全部内联进 workflow 脚本,`type` 白名单与 schema 的 `kind` 枚举都跟着注册表走。接口只有三个字段:`name`、`types`、`buildPrompt(input, opts)`。
|
|
84
85
|
|
|
85
86
|
---
|
|
86
87
|
|
|
@@ -101,7 +102,7 @@ deep-read-summarize 是 DSH 插件,可通过 npm、dsh.so 生态或本地安
|
|
|
101
102
|
npm install deep-read-summarize
|
|
102
103
|
|
|
103
104
|
# 或本地安装(dsh profile 目录)
|
|
104
|
-
pnpm add ./deep-read-summarize-0.3.
|
|
105
|
+
pnpm add ./deep-read-summarize-0.3.10.tgz
|
|
105
106
|
# 然后在 dsh 配置的 dsh.profile.bundles 追加:
|
|
106
107
|
# - deep-read-summarize
|
|
107
108
|
# 重启 dsh web 即可(POST /dsh-market/restart)
|
|
@@ -174,6 +175,10 @@ parsers: book, paper, video, web
|
|
|
174
175
|
"fastMode": false, // true 时跳过 5-7 节,速度快一些
|
|
175
176
|
"maxChunks": 4, // 分块上限,1-12(默认调低,控制子代理数与耗时)
|
|
176
177
|
"transcribe": true, // 视频:无字幕时自动本地转写(faster-whisper);false 则跳过转写,见「视频」节
|
|
178
|
+
"whisperModel": "small", // 视频转写模型档位:small | base | medium
|
|
179
|
+
"language": "zh", // 视频转写语言:纯英文视频可设 "en"
|
|
180
|
+
"device": "cpu", // 转写设备:cpu(默认)| auto | cuda;auto/cuda 需自备 CUDA 运行库,失败自动回退 cpu
|
|
181
|
+
"maxRetries": 0, // 质量校验重试次数(默认 0 = 不重试,重试会明显变慢)
|
|
177
182
|
"requireCitations": true, // 关键结论是否必须标注出处
|
|
178
183
|
"includeTimestamps": false,
|
|
179
184
|
"outputDir": "./output", // 笔记输出目录(可指向 Obsidian 仓库)
|
|
@@ -200,12 +205,12 @@ parsers: book, paper, video, web
|
|
|
200
205
|
> **⚠️ 为保证精读质量,处理时间可能略长(刻意取舍,不是卡死)**:**无字幕**视频会先做一次转写(CPU 上约为视频时长的 0.5–2×)再精读,所以这类视频整体会**明显比有字幕视频慢**;换来的是**完整逐字稿 + 真正的精读**。**有字幕**视频仍是秒级。请勿把转写的较慢误判为卡死。
|
|
201
206
|
|
|
202
207
|
1. **有平台字幕**(B站官方 API 的 AI 字幕 / YouTube CC)→ **直接用字幕**(=全文,最快、零依赖)。
|
|
203
|
-
2. **无公开字幕** → 用插件自带转写 `scripts/transcribe.
|
|
208
|
+
2. **无公开字幕** → 用插件自带转写 `scripts/transcribe.js`(faster-whisper small / int8 / VAD / 中文)得到全文。
|
|
204
209
|
3. 都不行 → **降级**:提示手动提供转写文本,或退回 `desc` 作背景;**绝不阻塞**。
|
|
205
210
|
|
|
206
211
|
`options.transcribe`:**默认 `true`**(无字幕自动转写);设为 `false` 则跳过转写(只用字幕/desc 或降级)。
|
|
207
212
|
|
|
208
|
-
**转写工具链(本机/用户一致)**:脚本**自举**——用 `uv` 建 **Python 3.12** 环境 + **清华镜像**装 `faster-whisper` + `HF_ENDPOINT=https://hf-mirror.com` 下模型并**缓存复用**;faster-whisper 内置 PyAV 解码音频,**无需单独 ffmpeg**;**版本已锁定**(Python 3.12 / faster-whisper / uv
|
|
213
|
+
**转写工具链(本机/用户一致)**:脚本**自举**——用 `uv` 建 **Python 3.12** 环境 + **清华镜像**装 `faster-whisper` + `HF_ENDPOINT=https://hf-mirror.com` 下模型并**缓存复用**;faster-whisper 内置 PyAV 解码音频,**无需单独 ffmpeg**;**版本已锁定**(Python 3.12 / faster-whisper / uv),保证本机与用户环境一致。脚本是 **Node** 写的,**Windows / macOS / Linux 同一份实现、同一条命令**(`node scripts/transcribe.js --audio <音频> --out <txt>`);转写默认走 **CPU**(`options.device` 默认 `cpu`),GPU 需自备 CUDA 运行库(cuBLAS/cuDNN),可设 `options.device: "auto"` 尝试,失败会自动回退 CPU。缓存目录按平台取:Windows `%LOCALAPPDATA%\deep-read-summarize`、macOS `~/Library/Caches/deep-read-summarize`、Linux `$XDG_CACHE_HOME/deep-read-summarize`。 装 Python 时默认走镜像加速,**镜像失败会自动改用直连 GitHub 重试**(镜像挂掉不该让用户彻底装不上);可用环境变量 `DRS_UV_PYTHON_MIRROR` 覆盖(设为空字符串 = 完全不用镜像)。
|
|
209
214
|
|
|
210
215
|
> ⚠️ **首次转写会先下载模型(small 约 484MB,走 hf-mirror,非 GitHub),可能需要几分钟**,请耐心等待;**本机只下这一次**,之后所有视频转写用缓存、秒开。**只有「无字幕」视频才会触发转写**(有字幕的视频直接用字幕,不触发、不下载)。
|
|
211
216
|
|
|
@@ -307,4 +312,4 @@ npm publish 会自动先跑 prepublishOnly(测试 + lint + 安全检查),
|
|
|
307
312
|
|
|
308
313
|
## License
|
|
309
314
|
|
|
310
|
-
MIT,见 [LICENSE](LICENSE)。
|
|
315
|
+
MIT,见 [LICENSE](LICENSE)。
|
package/cordis.patch.yml
CHANGED
|
@@ -10,13 +10,20 @@
|
|
|
10
10
|
- id: deep-read-summarize
|
|
11
11
|
name: 'deep-read-summarize'
|
|
12
12
|
|
|
13
|
-
# All plugin config keys are optional
|
|
13
|
+
# All plugin config keys are optional. The plugin validates each one (wrong type
|
|
14
|
+
# = warning + ignore, never a startup failure) and folds them into the default
|
|
15
|
+
# args carried by the skill, so they become this profile's defaults.
|
|
14
16
|
# config:
|
|
15
17
|
# outputDir: './output' # where notes are written (default: ./output)
|
|
16
18
|
# tempDir: './.tmp' # temp files for chunked content (default: ./.tmp)
|
|
17
|
-
# minWords: 2500 # minimum output length
|
|
18
|
-
# fastMode: false # skip sections 5-7 for speed
|
|
19
|
-
# maxChunks:
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
19
|
+
# minWords: 2500 # minimum output length (default: 2500)
|
|
20
|
+
# fastMode: false # skip sections 5-7 for speed (default: false)
|
|
21
|
+
# maxChunks: 4 # chunk cap; also caps sub-agent count (1-12, default: 4)
|
|
22
|
+
# transcribe: true # video: auto-transcribe when no subtitles (default: true)
|
|
23
|
+
# requireCitations: true # key conclusions must cite source location (default: true)
|
|
24
|
+
# includeTimestamps: false # video timestamps (default: false)
|
|
25
|
+
#
|
|
26
|
+
# Idempotency is deliberately NOT a plugin config key: the workflow script runs
|
|
27
|
+
# without a filesystem, so it cannot write a fingerprint record. Programmatic
|
|
28
|
+
# callers can use `deep-read-summarize/lib/cache`
|
|
29
|
+
# (fingerprint / hasProcessed / markProcessed).
|
package/docs/RELEASE.md
CHANGED
|
@@ -32,26 +32,86 @@
|
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
-
## npm
|
|
35
|
+
## npm 发布流程
|
|
36
|
+
|
|
37
|
+
### 首选:npm Trusted Publishing(OIDC,无 token、无 OTP)
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
.github/workflows/publish.yml ← 手动 dispatch(首选,可靠)/ Release 被发布 / 历史 tag 补发
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
凭据由 GitHub OIDC 在运行时现场换取,仓库里不存任何 npm token,也不会触发 npm 的 2FA 提示。
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 1. 本地全绿
|
|
47
|
+
npm run lint && npm test && npm run test:node && npm run validate
|
|
48
|
+
|
|
49
|
+
# 2. 打 tag 并推送(publish.yml 只接受 tag ref)
|
|
50
|
+
git tag -a vX.Y.Z -m "vX.Y.Z" && git push origin vX.Y.Z
|
|
51
|
+
|
|
52
|
+
# 3. 触发发布:手动 dispatch(可靠)。先干跑一次也行:加 -f dry_run=true
|
|
53
|
+
gh workflow run publish.yml --ref main -f publish_ref=refs/tags/vX.Y.Z
|
|
54
|
+
gh run watch
|
|
55
|
+
|
|
56
|
+
# 4. 建 Release(记录用;见下方「别把建 Release 当主路径」)
|
|
57
|
+
gh release create vX.Y.Z --title "vX.Y.Z" --notes-file <notes 文件> <从 npm 拉回的 tgz>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> ⚠️ **别把「建 Release」当发布主路径**:`release: published` 事件的投递**不稳**
|
|
61
|
+
> (实测:同一天里,给一个历史 tag 补建 Release 没触发,另一个又正常触发)。
|
|
62
|
+
> Release 仍然要建——用户看的是它——但**发布动作交给第 3 步的 dispatch**。
|
|
63
|
+
> 两条都跑时 workflow 是幂等的:第二次会跳过发布步骤并留一条 warning,不会变红。
|
|
64
|
+
|
|
65
|
+
**怎么算发成功了(判据,2026-09-24 实测)**:
|
|
66
|
+
|
|
67
|
+
1. **只看运行日志**:出现 `+ deep-read-summarize@X.Y.Z` 与 `Signed provenance statement`
|
|
68
|
+
(另有一条 sigstore 透明日志链接)。
|
|
69
|
+
2. **不要用 `npm view` 的即时结果判断**:registry 要 **1–2 分钟**才对外可见,
|
|
70
|
+
当场查必然是 **E404**、看着像失败(实测 t+40s 仍是 404,t+120s 才可见)。
|
|
71
|
+
3. **`--dry-run` 全绿不等于发布成功**:npm 的 OIDC 换票失败会被 CLI 静默吞掉,
|
|
72
|
+
真正的校验发生在写 registry 的那一刻(未配 Trusted Publisher 时报 404)。
|
|
73
|
+
4. 最后再 `npm view deep-read-summarize dist-tags --json --prefer-online` 复核 `latest`。
|
|
74
|
+
|
|
75
|
+
**发完别忘了**:用 `npm pack <包>@<版本>` 拉回 registry 那一份字节,挂成 Release 资产
|
|
76
|
+
(本地构建的 tarball 与 CI 的不保证同字节),并把 SHA-256 写进 release notes。
|
|
77
|
+
|
|
78
|
+
**前置(每个包一次性,只能在网页上配)**:
|
|
79
|
+
`https://www.npmjs.com/package/<包名>/access` → Trusted Publishers → Add,填
|
|
80
|
+
Provider `GitHub Actions` / Organization or user `PensiveFei` / Repository `deep-read-summarize` /
|
|
81
|
+
Workflow filename `publish.yml` / Environment 留空。
|
|
82
|
+
|
|
83
|
+
**历史 tag 里没有这个 workflow 时**(workflow 定义从 main 取,包内容从 tag 取):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
gh workflow run publish.yml --ref main -f publish_ref=refs/tags/vX.Y.Z
|
|
87
|
+
gh run watch
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 回退:本地发布(需要交互式 2FA)
|
|
91
|
+
|
|
92
|
+
> ⚠️ 2026-07 起 npm 已限制「绕过 2FA 的 granular access token」用于**直接发布**,
|
|
93
|
+
> 所以本地发布只能靠交互式 OTP —— 不再有「建个长期 token 一劳永逸」这条路。
|
|
36
94
|
|
|
37
95
|
```bash
|
|
38
96
|
cd <项目目录>
|
|
39
|
-
npm run lint && npm test && npm run validate # 先本地全绿
|
|
40
|
-
npm
|
|
41
|
-
npm
|
|
42
|
-
npm view deep-read-summarize --prefer-online # 验证线上(注意:发布后首次查询可能 404,索引有延迟)
|
|
97
|
+
npm run lint && npm test && npm run test:node && npm run validate # 先本地全绿
|
|
98
|
+
npm publish --otp=<6位码> # prepublishOnly 自动跑门禁
|
|
99
|
+
npm view deep-read-summarize --prefer-online # 验证线上(首次查询可能索引延迟)
|
|
43
100
|
```
|
|
44
101
|
|
|
45
|
-
-
|
|
46
|
-
- 本沙箱环境 npm 默认缓存目录可能被拒(EPERM),用 npm publish --cache <工作区内目录>
|
|
102
|
+
- 本沙箱环境 npm 默认缓存目录可能被拒(EPERM),用 `npm publish --cache <可写目录>`
|
|
47
103
|
- 版本号:功能增强 → minor(0.x → 0.y);修复 → patch;不兼容 → major
|
|
48
104
|
|
|
49
105
|
## 当前版本速览
|
|
50
106
|
|
|
51
107
|
| 版本 | 状态 | 说明 |
|
|
52
108
|
|------|------|------|
|
|
53
|
-
| v0.1.0/v0.1.1 | git tag | 早期迭代,未上 npm |
|
|
109
|
+
| v0.1.0 / v0.1.1 | git tag | 早期迭代,未上 npm |
|
|
54
110
|
| v0.2.x | npm 已发布 | 首个 npm 版本,含发布门禁 |
|
|
111
|
+
| v0.3.0 – v0.3.7 | npm 已发布 | 解析器插件化、幂等缓存、视频转写流水线 |
|
|
112
|
+
| v0.3.8 | **仅 GitHub** | 打了 tag 与 Release 但漏发到 npm(Trusted Publishing 迁移期的缺口;修复已随 0.3.9 交付) |
|
|
113
|
+
| v0.3.9 | npm 已发布 | macOS / Linux 支持(转写链路跨平台) |
|
|
114
|
+
| **v0.3.10** | **npm 已发布(当前)** | 修:失效的 uv 镜像、空转写被当成成功、发布文档过时 |
|
|
55
115
|
| v1.0.0 | 计划 | API 稳定后发布 |
|
|
56
116
|
|
|
57
117
|
> 早期迭代用 0.x 表达不稳定;API 稳定后再发 1.0.0。
|
package/index.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
// ============================================================================
|
|
2
2
|
// deep-read-summarize — DSH plugin entry
|
|
3
3
|
// ============================================================================
|
|
4
|
-
// 标准 Cordis 插件(DSH 0.1.x 契约,已在 0.1.2-rc.1 实测):导出 name + inject + apply(ctx)。
|
|
4
|
+
// 标准 Cordis 插件(DSH 0.1.x 契约,已在 0.1.2-rc.1 实测):导出 name + inject + apply(ctx, config)。
|
|
5
5
|
// apply() 将插件自带的 SKILL.md 注册为运行时技能,并把 workflow 的
|
|
6
6
|
// meta + 自包含 script + args 示例嵌入技能内容,使模型可直接用 workflow
|
|
7
7
|
// 工具执行精读流程。
|
|
8
8
|
//
|
|
9
|
+
// config:插件级默认 options(cordis.patch.yml 的 config 段)。此前 apply()
|
|
10
|
+
// 收了 config 却从不读它——配置文件里写的那些键全是空转。现在这些键会被
|
|
11
|
+
// 校验、合并进技能里的 args 示例,成为该 profile 的默认值。
|
|
12
|
+
//
|
|
9
13
|
// 同时保留 load / workflow / parsers / schemas 导出,兼容旧式加载读取。
|
|
10
14
|
// 安装方式(dsh profile 目录): pnpm add ./xxx.tgz → dsh.profile.bundles 追加
|
|
11
15
|
// ============================================================================
|
|
@@ -20,10 +24,58 @@ const schemas = require('./schemas');
|
|
|
20
24
|
module.exports.name = 'deep-read-summarize';
|
|
21
25
|
module.exports.inject = ['skills'];
|
|
22
26
|
|
|
27
|
+
/** workflow 的 options 默认值(与 workflow 脚本内的默认值保持一致)。 */
|
|
28
|
+
const DEFAULT_OPTIONS = {
|
|
29
|
+
minWords: 2500,
|
|
30
|
+
fastMode: false,
|
|
31
|
+
maxChunks: 4,
|
|
32
|
+
transcribe: true,
|
|
33
|
+
requireCitations: true,
|
|
34
|
+
includeTimestamps: false,
|
|
35
|
+
outputDir: './output',
|
|
36
|
+
tempDir: './.tmp'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const OPTION_TYPES = {
|
|
40
|
+
minWords: 'number',
|
|
41
|
+
fastMode: 'boolean',
|
|
42
|
+
maxChunks: 'number',
|
|
43
|
+
transcribe: 'boolean',
|
|
44
|
+
requireCitations: 'boolean',
|
|
45
|
+
includeTimestamps: 'boolean',
|
|
46
|
+
outputDir: 'string',
|
|
47
|
+
tempDir: 'string'
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 归一化插件 config:只认白名单里的键,类型不符就告警并忽略(不抛错,
|
|
52
|
+
* 免得一个拼错的配置项把整个 profile 拖死)。
|
|
53
|
+
* 支持 `config: { outputDir: ... }` 与 `config: { options: { outputDir: ... } }` 两种写法。
|
|
54
|
+
*/
|
|
55
|
+
function normalizeOptions(config) {
|
|
56
|
+
const opts = { ...DEFAULT_OPTIONS };
|
|
57
|
+
const raw = (config && config.options) || config || {};
|
|
58
|
+
for (const key of Object.keys(DEFAULT_OPTIONS)) {
|
|
59
|
+
const v = raw[key];
|
|
60
|
+
if (v === undefined) continue;
|
|
61
|
+
if (typeof v !== OPTION_TYPES[key]) {
|
|
62
|
+
console.warn('[deep-read-summarize] ignoring config.' + key + ' — expected ' + OPTION_TYPES[key] + ', got ' + typeof v);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
opts[key] = v;
|
|
66
|
+
}
|
|
67
|
+
return opts;
|
|
68
|
+
}
|
|
69
|
+
|
|
23
70
|
/** 组装技能内容:SKILL.md + workflow meta/script/args 示例(script 为自包含版本)。 */
|
|
24
|
-
function buildSkillContent() {
|
|
71
|
+
function buildSkillContent(config = {}) {
|
|
25
72
|
const skillDir = path.join(__dirname, 'skills', 'deep-read-summarize');
|
|
26
73
|
const body = readFileSync(path.join(skillDir, 'SKILL.md'), 'utf8');
|
|
74
|
+
const argsExample = {
|
|
75
|
+
input: '<链接或本地路径>',
|
|
76
|
+
type: 'auto',
|
|
77
|
+
options: normalizeOptions(config)
|
|
78
|
+
};
|
|
27
79
|
return [
|
|
28
80
|
body.trim(),
|
|
29
81
|
'',
|
|
@@ -35,14 +87,14 @@ function buildSkillContent() {
|
|
|
35
87
|
JSON.stringify(workflow.meta, null, 2),
|
|
36
88
|
'```',
|
|
37
89
|
'',
|
|
38
|
-
'script(完整脚本,原样填入 script
|
|
90
|
+
'script(完整脚本,原样填入 script 参数;脚本已自包含解析器,无需宿主注入):',
|
|
39
91
|
'```javascript',
|
|
40
92
|
workflow.script,
|
|
41
93
|
'```',
|
|
42
94
|
'',
|
|
43
|
-
'args
|
|
95
|
+
'args 示例(options 是本 profile 的默认值,用户另有要求时再覆盖):',
|
|
44
96
|
'```json',
|
|
45
|
-
|
|
97
|
+
JSON.stringify(argsExample, null, 2),
|
|
46
98
|
'```'
|
|
47
99
|
].join('\n');
|
|
48
100
|
}
|
|
@@ -54,7 +106,7 @@ function apply(ctx, config = {}) {
|
|
|
54
106
|
name: 'deep-read-summarize',
|
|
55
107
|
description: workflow.meta.description,
|
|
56
108
|
whenToUse: workflow.meta.whenToUse,
|
|
57
|
-
content: buildSkillContent(),
|
|
109
|
+
content: buildSkillContent(config),
|
|
58
110
|
resourceBase: { kind: 'directory', path: skillDir },
|
|
59
111
|
// source 是技能的「来源桶」(runtime / bundled / user-dsh …),不是自由描述:
|
|
60
112
|
// 本技能随插件包分发,因此登记为 bundled。
|
|
@@ -73,3 +125,5 @@ module.exports.workflow = workflow;
|
|
|
73
125
|
module.exports.parsers = parsers;
|
|
74
126
|
module.exports.schemas = schemas;
|
|
75
127
|
module.exports.buildSkillContent = buildSkillContent;
|
|
128
|
+
module.exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
|
|
129
|
+
module.exports.normalizeOptions = normalizeOptions;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deep-read-summarize",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Deep reading & summarization for DSH: books/papers/videos/web → structured Obsidian notes. Plugin parsers, MapReduce deep-read, JSON Schema
|
|
3
|
+
"version": "0.3.10",
|
|
4
|
+
"description": "Deep reading & summarization for DSH: books/papers/videos/web → structured Obsidian notes. Plugin parsers, MapReduce deep-read, JSON Schema-constrained sub-tasks.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"exports": {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"./workflow": "./workflow.js",
|
|
10
10
|
"./parsers": "./parsers/index.js",
|
|
11
11
|
"./schemas": "./schemas/index.js",
|
|
12
|
+
"./lib/cache": "./lib/cache.js",
|
|
12
13
|
"./package.json": "./package.json"
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"validate": "node tests/quick_validate.js && node scripts/security-check.js",
|
|
36
37
|
"security": "node scripts/security-check.js",
|
|
37
38
|
"test:node": "node --test",
|
|
38
|
-
"prepublishOnly": "node tests/run-tests.js && node scripts/lint.js && node scripts/security-check.js"
|
|
39
|
+
"prepublishOnly": "node tests/run-tests.js && node --test && node scripts/lint.js && node scripts/security-check.js"
|
|
39
40
|
},
|
|
40
41
|
"dsh": {
|
|
41
42
|
"bundle": {
|
package/parsers/book.js
CHANGED
|
@@ -20,7 +20,7 @@ module.exports = {
|
|
|
20
20
|
fetchTarget: "书籍全文",
|
|
21
21
|
kindLabel: "书籍(book)",
|
|
22
22
|
steps: [
|
|
23
|
-
"获取全文:PDF
|
|
23
|
+
"获取全文:PDF→优先用 read 读取;读不出正文时用 pdftotext(poppler 命令行工具,三平台通用;未装时按系统装:macOS `brew install poppler`、Windows `winget install poppler`、Debian/Ubuntu `apt install poppler-utils`);扫描版 PDF 需 OCR;EPUB/MOBI→解包或转文本;纯文本→直接读取。",
|
|
24
24
|
"全文写入目标文件(不截断、不加评注),用 read 确认总行数。",
|
|
25
25
|
"识别书籍结构:目录/序言/各章节标题及其行号范围。"
|
|
26
26
|
],
|