deep-read-summarize 0.6.2 → 0.6.4
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 +47 -0
- package/README.en.md +7 -0
- package/README.md +7 -0
- package/cordis.patch.yml +1 -0
- package/docs/RELEASE.md +3 -1
- package/index.js +11 -3
- package/lib/options.js +8 -1
- package/lib/workflow-script.txt +47 -5
- package/package.json +7 -3
- package/parsers/_prompt.js +2 -1
- package/parsers/book.js +1 -1
- package/parsers/paper.js +1 -1
- package/parsers/video.js +4 -4
- package/parsers/web.js +1 -1
- package/skills/deep-read-summarize/SKILL.md +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,53 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.6.4] — 2026-11-15
|
|
9
|
+
|
|
10
|
+
让未通过核验的笔记保留清晰状态与原因,并支持直接请求简洁精读笔记。
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- 质量未通过时,在保存的笔记中保留质量提示、失败分块和最多五项问题;Obsidian 与 generic 模板中可安全识别的完成状态改为“待核验”。原始 `qualityIssues` 完整保留;无法明确识别的成稿不被丢弃,通过核验的笔记正文保持不变。
|
|
15
|
+
- 新增可显式调用的 `lengthMode: "concise"`:默认 `minWords: 500`、`fastMode: true`,独立原文核验不变。单独指定的篇幅和章节设置优先于预设;成稿模板不再固定要求概述约 500 字。`minWords` 是最低计数,不是输出上限。
|
|
16
|
+
- **补充中文项目描述与关键词**:更新 `package.json` 中的项目描述与关键词,并同步更新 GitHub 仓库描述。
|
|
17
|
+
|
|
18
|
+
### Verification
|
|
19
|
+
|
|
20
|
+
- 增加模拟工作流回归测试,覆盖三种 frontmatter、核验失败、失败分块、异常内容、CRLF 与含 Markdown/HTML 的核验问题,以及简洁模式、参数优先级和独立核验;通过结果和未能提取的原始成稿仍受回归测试保护。
|
|
21
|
+
- 本次未运行真实模型端到端调用;对话中的简洁请求仍取决于宿主代理遵循技能说明。
|
|
22
|
+
|
|
23
|
+
### Compatibility
|
|
24
|
+
|
|
25
|
+
- 标准模式的默认篇幅、章节和核验门槛不变;简洁模式按需启用。质量未通过时,返回的 `note` 会包含程序追加的提示,且模板状态可能从“已完成”变为“待核验”;通过时不添加提示。
|
|
26
|
+
|
|
27
|
+
## [0.6.3] — 2026-11-12
|
|
28
|
+
|
|
29
|
+
修复获取阶段把「子代理没有返回结构化结果」误报成内容获取失败的问题,并让获取提示词的 JSON 示例合法、可被结构化输出接受。
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- **两种获取失败被合并成一句话**:子代理失败时 `agent()` 兑现 `null`(没调用 `structured_output`,或运行失败),这与子代理明确返回 `{ "saved": false }` 不是同一件事——内容可能已经写入目标文件。此前两者共用「获取失败(可降级:检查输入或手动提供文本)」,把结果通道的问题说成来源问题,让用户回头重查一个本来没问题的链接。现在前者单独报告「未收到可用的获取结果」,后者保留子代理自报的 `message`,抛错路径不变。
|
|
34
|
+
- **获取提示词的示例不合法**:四个内置解析器的 JSON 示例里 `"totalLines": N` 不是合法 JSON,`"language": "zh|en"` 超出 `fetchResultSchema` 的枚举,视频解析器的 `"textSource"` 同样是「多选一」的写法。模型照抄示例时,`structured_output` 会以参数校验失败拒绝——正好落进上面那条死路。示例改为合法取值,并在提示词里写明这些字段必须填本次实际值(照抄示例行数会截断原文)。
|
|
35
|
+
- **提示词与宿主的结构化输出要求相抵**:获取与类型识别提示词都以「只输出 JSON」结尾,等于教子代理把 JSON 写在正文里;宿主的要求是必须以 `structured_output` 工具调用结束。改为按结构化输出通道提交。
|
|
36
|
+
|
|
37
|
+
### Verification
|
|
38
|
+
|
|
39
|
+
- 用确定性子代理重放获取阶段的四种返回值:`null`、`{ "saved": false }`、带 `message` 的 `{ "saved": false }` 以及抛错,确认前两条的消息不再相同、`message` 原样保留、抛错路径不变(`tests/workflow-regressions.test.js`)。
|
|
40
|
+
- 新增示例校验测试:四个内置解析器的示例必须能被 `JSON.parse`,且 `language` 落在 schema 枚举内、`totalLines` 为数字、视频 `textSource` 在文档允许的取值内(`tests/parser-entry-audit.test.js`)。
|
|
41
|
+
- 本地 Node 24 上 `npm test`、`npm run test:node`、`npm run lint`、`npm run security`、`npm run validate` 全绿;本次未做真实模型端到端调用。
|
|
42
|
+
|
|
43
|
+
### Compatibility
|
|
44
|
+
|
|
45
|
+
- 升级无需更改配置;返回结构(`ok` / `stage` / `fatal`)不变,变化只在失败消息文案与提示词。已有缓存与已保存的成稿不受影响。
|
|
46
|
+
|
|
47
|
+
### 已知问题
|
|
48
|
+
|
|
49
|
+
- 宿主把「子代理没调用 `structured_output`」和「子代理运行失败」都兑现成 `null`,插件无法区分,只能如实报告「未收到可用的获取结果」,不再猜测属于哪一种。
|
|
50
|
+
|
|
51
|
+
### 贡献者与致谢
|
|
52
|
+
|
|
53
|
+
- 感谢 @qneko 报告并复现获取阶段错误信息合并、提示词示例不合法的问题,并附上受控重放结果([Issue #10](https://github.com/PensiveFei/deep-read-summarize/issues/10))。
|
|
54
|
+
|
|
8
55
|
## [0.6.2] — 2026-11-11
|
|
9
56
|
|
|
10
57
|
修复成稿包含前言或外层 Markdown 围栏时,笔记被误判为格式、篇幅和引用不合格的问题。
|
package/README.en.md
CHANGED
|
@@ -63,6 +63,8 @@ https://arxiv.org/abs/2307.09042
|
|
|
63
63
|
|
|
64
64
|
You can also provide a local file, web page, or video link. If needed, specify an output location, sections to retain, or whether you want timestamps.
|
|
65
65
|
|
|
66
|
+
For a shorter note, ask for “a concise reading note with key points, terminology, and quotations.” The main agent can select concise mode, which defaults to a minimum count of 500 and omits sections 5–7 while retaining source review. Ask explicitly if you also want critical analysis or the other optional sections. The minimum is not a length cap; the model determines the actual output length.
|
|
67
|
+
|
|
66
68
|
Hosts with plugin-tool support register `deep_read_summarize`; older hosts use the bundled skill and workflow entry point. The tool returns the note and a suggested path; **the main agent must write the file**. Check that the file was saved and whether the result reports gaps or quality issues.
|
|
67
69
|
|
|
68
70
|
When an identifiable note is extracted from a wrapper, the optional `draftContext` field records the extraction and retains any surrounding text. That text is not part of the note reviewed against the source.
|
|
@@ -89,6 +91,8 @@ When an identifiable note is extracted from a wrapper, the optional `draftContex
|
|
|
89
91
|
|
|
90
92
|
The workflow normalizes chunk ranges and checks coverage of known source line numbers. After drafting, code checks format and length, and an independent review agent reads the obtained text to check chunk coverage and key quotations. Results are available through `qualityPassed`, `qualityChecks`, and `qualityEvidence`.
|
|
91
93
|
|
|
94
|
+
When quality checks fail, the saved note includes a notice, failed chunks, and up to five issues. The completion status in the default Obsidian and generic templates is changed to “pending review” when it can be identified safely. The complete issue list remains in `qualityIssues`.
|
|
95
|
+
|
|
92
96
|
These checks have limits:
|
|
93
97
|
|
|
94
98
|
- **`qualityPassed` does not prove factual accuracy.** Coverage and source authenticity still depend on the reviewing agent reading and evaluating the source. Check important claims, numbers, and quotations yourself.
|
|
@@ -100,6 +104,7 @@ These checks have limits:
|
|
|
100
104
|
|
|
101
105
|
| Option | Default | Purpose |
|
|
102
106
|
| --- | --- | --- |
|
|
107
|
+
| `lengthMode` | `standard` | Set to `concise` for the preset: `minWords: 500` and `fastMode: true` by default |
|
|
103
108
|
| `minWords` | `2500` | Minimum length; the check counts Chinese characters and words in other text |
|
|
104
109
|
| `fastMode` | `false` | Omit the critical analysis, personal applications, and further-reading sections |
|
|
105
110
|
| `maxChunks` | `4` | Chunk-count limit, capped at 12; this is not the concurrency setting |
|
|
@@ -115,6 +120,8 @@ These checks have limits:
|
|
|
115
120
|
| `parallelQuality` | `false` | Opt in to parallel source review; the original review path remains the default |
|
|
116
121
|
| `readCache` | `false` | Optional cross-run chunk cache; supported by the plugin tool only |
|
|
117
122
|
|
|
123
|
+
For a direct call, use `options: { "lengthMode": "concise" }`. Explicit `minWords` and `fastMode` values in that call override the preset; for example, `"fastMode": false` retains all sections. Concise mode aims near the minimum but does not impose a maximum length.
|
|
124
|
+
|
|
118
125
|
To enable `readCache`, also set `readCacheIdentity` to include the provider, pinned model version, and output-affecting settings; change it whenever those change. The caller supplies this identity, and the host cannot verify it automatically. Cache entries are local plaintext and may contain source excerpts; cache hits still receive independent source review.
|
|
119
126
|
|
|
120
127
|
Other options include `frontmatter` (`obsidian`, `generic`, or `minimal`) and `tempDir`. See the [advanced reference](https://github.com/PensiveFei/deep-read-summarize/blob/main/docs/README-reference.en.md) for detailed options, supported formats, and transcription and cache behavior.
|
package/README.md
CHANGED
|
@@ -63,6 +63,8 @@ https://arxiv.org/abs/2307.09042
|
|
|
63
63
|
|
|
64
64
|
你也可以提供本地文件路径、网页或视频链接。如果需要,可以在请求中说明输出位置、希望保留的章节或是否需要时间戳。
|
|
65
65
|
|
|
66
|
+
想要短一些,可以说“请生成简洁笔记,保留要点、术语和关键引用”。主代理可选择简洁模式,默认最低计数为 500 并省略第 5–7 节,仍保留原文核验;如需批判分析等章节,可以在请求中说明。最低篇幅并非字数上限,实际长度仍由模型决定。
|
|
67
|
+
|
|
66
68
|
支持插件工具的宿主会注册 `deep_read_summarize`;旧宿主使用插件提供的技能和 workflow 入口。精读工具返回笔记正文及建议路径,**实际写入文件需要由主代理完成**。生成后请确认文件已保存,并检查结果中是否报告内容缺口或质量问题。
|
|
67
69
|
|
|
68
70
|
当工作流提取被包装的笔记时,可选字段 `draftContext` 会记录提取方式,以及模型在笔记前后附带的额外说明。这些额外文字不是经过原文核验的笔记正文。
|
|
@@ -89,6 +91,8 @@ https://arxiv.org/abs/2307.09042
|
|
|
89
91
|
|
|
90
92
|
工作流会规范化分块范围,检查已知原文行号的覆盖情况;成稿后,程序检查格式和篇幅,并由独立核验代理读取取得的文本,检查分块覆盖与关键引文。核验结果可通过 `qualityPassed`、`qualityChecks` 和 `qualityEvidence` 查看。
|
|
91
93
|
|
|
94
|
+
质量未通过时,保存的笔记开头会保留提示、失败分块及最多 5 项问题;默认 Obsidian 和 generic 模板中的完成状态会在可安全识别时改为“待核验”。完整问题列表仍在 `qualityIssues` 中。
|
|
95
|
+
|
|
92
96
|
这些检查有边界:
|
|
93
97
|
|
|
94
98
|
- **`qualityPassed` 不是事实正确性的证明。**覆盖和原文真实性判断仍依赖核验代理实际读取与判断;重要结论、数字和引用请自行复核。
|
|
@@ -100,6 +104,7 @@ https://arxiv.org/abs/2307.09042
|
|
|
100
104
|
|
|
101
105
|
| 选项 | 默认值 | 用途 |
|
|
102
106
|
| --- | --- | --- |
|
|
107
|
+
| `lengthMode` | `standard` | 设为 `concise` 使用简洁预设,默认 `minWords: 500`、`fastMode: true` |
|
|
103
108
|
| `minWords` | `2500` | 最低篇幅要求;检查规则按中文字符和其他文字的词计算 |
|
|
104
109
|
| `fastMode` | `false` | 开启后省略批判性分析、个人应用和延伸阅读章节 |
|
|
105
110
|
| `maxChunks` | `4` | 分块数量上限,最大为 12;不是并发数 |
|
|
@@ -115,6 +120,8 @@ https://arxiv.org/abs/2307.09042
|
|
|
115
120
|
| `parallelQuality` | `false` | 显式启用并行原文核验;默认保留原核验路径 |
|
|
116
121
|
| `readCache` | `false` | 可选的跨次精读缓存;仅插件工具入口支持 |
|
|
117
122
|
|
|
123
|
+
直接调用时可用 `options: { "lengthMode": "concise" }`。同一次调用显式提供的 `minWords`、`fastMode` 优先于预设;例如加上 `"fastMode": false` 可保留完整章节。简洁模式尽量接近最低篇幅,但不限制最大字数。
|
|
124
|
+
|
|
118
125
|
开启 `readCache` 时,还必须提供 `readCacheIdentity`,写明供应商、固定模型版本及影响输出的设置;这些信息变化时需更换身份。该身份由调用者提供,宿主无法自动验证。缓存为本地明文,可能包含原文摘录;命中后仍会执行独立原文核验。
|
|
119
126
|
|
|
120
127
|
其他选项包括 `frontmatter`(`obsidian`、`generic`、`minimal`)和 `tempDir`。高级选项、取值范围、转写缓存和自定义解析器可参考[完整配置与技术参考](https://github.com/PensiveFei/deep-read-summarize/blob/main/docs/README-reference.zh.md)。
|
package/cordis.patch.yml
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
# customParsersDir: './custom-parsers' # optional plugin-level parser directory (not a workflow option)
|
|
18
18
|
# outputDir: './output' # where notes are written (default: ./output)
|
|
19
19
|
# tempDir: './.tmp' # temp files for chunked content (default: ./.tmp)
|
|
20
|
+
# lengthMode: 'standard' # standard | concise; concise defaults to 500 and fastMode
|
|
20
21
|
# minWords: 2500 # minimum output length (default: 2500)
|
|
21
22
|
# fastMode: false # skip sections 5-7 for speed (default: false)
|
|
22
23
|
# maxChunks: 4 # chunk cap; also caps sub-agent count (1-12, default: 4)
|
package/docs/RELEASE.md
CHANGED
|
@@ -157,7 +157,9 @@ npm view deep-read-summarize --prefer-online # 验证线
|
|
|
157
157
|
| v0.5.0 | npm 已发布 | 无字幕视频新增逐字稿内容缓存、转写阶段计时和 CPU 线程配置,保留默认精读与原文核验门槛。 |
|
|
158
158
|
| v0.6.0 | npm 已发布 | 新增可配置并发、字符均衡分块与可选的并行原文核验和跨次精读缓存,保留原有默认核验路径。 |
|
|
159
159
|
| v0.6.1 | npm 已发布 | 修复普通执行路径的结果序列化错误,避免已生成的精读笔记在返回宿主时被丢弃。 |
|
|
160
|
-
|
|
|
160
|
+
| v0.6.2 | npm 已发布 | 修复成稿包含前言或外层 Markdown 围栏时,笔记被误判为格式、篇幅和引用不合格的问题。 |
|
|
161
|
+
| v0.6.3 | npm 已发布 | 修复获取阶段把「子代理没有返回结构化结果」误报成内容获取失败的问题,并让获取提示词的 JSON 示例合法、可被结构化输出接受。 |
|
|
162
|
+
| **v0.6.4** | **npm 已发布(当前)** | 让未通过核验的笔记保留清晰状态与原因,并支持直接请求简洁精读笔记。 |
|
|
161
163
|
| v1.0.0 | 计划 | API 稳定后发布 |
|
|
162
164
|
|
|
163
165
|
> 早期迭代用 0.x 表达不稳定;API 稳定后再发 1.0.0。
|
package/index.js
CHANGED
|
@@ -62,7 +62,7 @@ function buildSkillContent(config = {}, runtime = {}) {
|
|
|
62
62
|
if (runtime.toolName) {
|
|
63
63
|
return [body.trim(), '', '## 调用精读工具',
|
|
64
64
|
'调用 `' + runtime.toolName + '`,只提交 input / type / options。工具返回完整 note 与建议 filePath;必须按上文执行同名文件询问、落盘和质量报告。',
|
|
65
|
-
'args 示例(options 是本 profile
|
|
65
|
+
'args 示例(options 是本 profile 的默认值;选择 lengthMode 预设时,省略用户未明确指定的 minWords 和 fastMode,以免示例默认值覆盖预设):',
|
|
66
66
|
'```json', JSON.stringify(argsExample, null, 2), '```'].join('\n');
|
|
67
67
|
}
|
|
68
68
|
return [
|
|
@@ -81,7 +81,7 @@ function buildSkillContent(config = {}, runtime = {}) {
|
|
|
81
81
|
workflow.buildSelfContainedScript(runtime.registry || configuredRegistry(config)),
|
|
82
82
|
'```',
|
|
83
83
|
'',
|
|
84
|
-
'args 示例(options 是本 profile
|
|
84
|
+
'args 示例(options 是本 profile 的默认值;选择 lengthMode 预设时,省略用户未明确指定的 minWords 和 fastMode,以免示例默认值覆盖预设):',
|
|
85
85
|
'```json',
|
|
86
86
|
JSON.stringify(argsExample, null, 2),
|
|
87
87
|
'```'
|
|
@@ -118,7 +118,15 @@ function readingTool(engine, defaults, registry) {
|
|
|
118
118
|
if (typeof args.input !== 'string' || !args.input.trim()) throw new Error('[FATAL] args.input 必须是非空字符串');
|
|
119
119
|
if (args.type !== undefined && typeof args.type !== 'string') throw new Error('[FATAL] args.type 必须是字符串');
|
|
120
120
|
if (args.options !== undefined && (!args.options || typeof args.options !== 'object' || Array.isArray(args.options))) throw new Error('[FATAL] options 必须是对象');
|
|
121
|
-
const
|
|
121
|
+
const overrides = args.options || {};
|
|
122
|
+
const merged = Object.assign({}, defaults, overrides);
|
|
123
|
+
// Selecting a preset for this invocation replaces the profile's length
|
|
124
|
+
// defaults, but explicit per-invocation choices still take precedence.
|
|
125
|
+
if (Object.prototype.hasOwnProperty.call(overrides, 'lengthMode') && overrides.lengthMode !== undefined) {
|
|
126
|
+
if (overrides.minWords === undefined) delete merged.minWords;
|
|
127
|
+
if (overrides.fastMode === undefined) delete merged.fastMode;
|
|
128
|
+
}
|
|
129
|
+
const options = normalizeWorkflowOptions(merged);
|
|
122
130
|
if (!exec || !exec.agent) throw new Error('deep_read_summarize requires a calling agent');
|
|
123
131
|
if (exec.signal && exec.signal.aborted) throw new Error('deep_read_summarize was cancelled before start');
|
|
124
132
|
const startArgs = { input: args.input, type: args.type || 'auto', options: options };
|
package/lib/options.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/** Kept self-contained: the exact same validator is embedded in the workflow. */
|
|
4
4
|
function normalizeWorkflowOptions(raw, behavior) {
|
|
5
5
|
const defaults = {
|
|
6
|
-
minWords: 2500, fastMode: false, maxChunks: 4, readConcurrency: 3, parallelQuality: false, transcribe: true,
|
|
6
|
+
lengthMode: 'standard', minWords: 2500, fastMode: false, maxChunks: 4, readConcurrency: 3, parallelQuality: false, transcribe: true,
|
|
7
7
|
requireCitations: true, includeTimestamps: false, outputDir: './output',
|
|
8
8
|
tempDir: './.tmp', whisperModel: 'small', language: 'zh', device: 'cpu',
|
|
9
9
|
maxRetries: 0, frontmatter: 'obsidian', cpuThreads: 0, transcriptCache: true,
|
|
@@ -22,6 +22,12 @@ function normalizeWorkflowOptions(raw, behavior) {
|
|
|
22
22
|
invalid('', 'expected an options object');
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
25
|
+
// Apply the preset before the individual fields so explicit settings win.
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(raw, 'lengthMode') && typeof raw.lengthMode === 'string' &&
|
|
27
|
+
!/[\u0000\r\n]/.test(raw.lengthMode) && raw.lengthMode.trim().toLowerCase() === 'concise') {
|
|
28
|
+
result.minWords = 500;
|
|
29
|
+
result.fastMode = true;
|
|
30
|
+
}
|
|
25
31
|
const keys = Object.keys(defaults);
|
|
26
32
|
const unknown = Object.keys(raw).filter(function (key) { return keys.indexOf(key) < 0; });
|
|
27
33
|
if (unknown.length) {
|
|
@@ -56,6 +62,7 @@ function normalizeWorkflowOptions(raw, behavior) {
|
|
|
56
62
|
reason = 'expected a non-empty string without NUL or line breaks';
|
|
57
63
|
} else if (key !== 'outputDir' && key !== 'tempDir') {
|
|
58
64
|
value = value.trim().toLowerCase();
|
|
65
|
+
if (key === 'lengthMode' && ['standard', 'concise'].indexOf(value) < 0) reason = 'expected standard|concise';
|
|
59
66
|
if (key === 'frontmatter' && ['obsidian', 'generic', 'minimal'].indexOf(value) < 0) reason = 'expected obsidian|generic|minimal';
|
|
60
67
|
if (key === 'device' && ['cpu', 'auto', 'cuda'].indexOf(value) < 0) reason = 'expected cpu|auto|cuda';
|
|
61
68
|
if (key === 'whisperModel' && models.indexOf(value) < 0) reason = 'unsupported Whisper model';
|
package/lib/workflow-script.txt
CHANGED
|
@@ -24,6 +24,7 @@ if (args && args.type !== undefined && typeof args.type !== "string") throw new
|
|
|
24
24
|
const input = (args && args.input || "").trim();
|
|
25
25
|
const forcedType = ((args && args.type) || "auto").toLowerCase();
|
|
26
26
|
const options = normalizeWorkflowOptions(args && args.options);
|
|
27
|
+
const lengthMode = options.lengthMode;
|
|
27
28
|
const minWords = options.minWords;
|
|
28
29
|
const fastMode = options.fastMode;
|
|
29
30
|
const maxChunks = options.maxChunks;
|
|
@@ -99,7 +100,7 @@ if (!cacheResume && forcedType === "auto") {
|
|
|
99
100
|
required: ["kind"], additionalProperties: false
|
|
100
101
|
};
|
|
101
102
|
const detectPrompt = [
|
|
102
|
-
"
|
|
103
|
+
"识别输入内容类型,选择后续获取全文所需的解析器,按 {\"kind\": \"类型\"} 提交结构化结果(不要把 JSON 只写在正文里)。",
|
|
103
104
|
"可用类型:" + parserNames.join(", ") + "。book=书籍,paper=学术论文,video=视频,web=网页/文章。",
|
|
104
105
|
"PDF 既可能是书籍也可能是论文;未知网站可能承载论文或在线书籍,不要仅凭扩展名或网页形式判断。",
|
|
105
106
|
"必要时只查看标题、摘要、目录或页面元信息,不获取或精读全文,不写入文件。",
|
|
@@ -145,9 +146,16 @@ catch (error) {
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
// 失败纪律:内容获取失败 = 可降级错误(返回失败结果,不抛 fatal)
|
|
148
|
-
|
|
149
|
+
// agent() 以 null 兑现子代理失败,这与「子代理明确报告 saved:false」不是一回事:
|
|
150
|
+
// null 只说明没拿到结构化结果(可能没调用 structured_output,或子代理运行失败),
|
|
151
|
+
// 不能据此断言内容没取到——把两者并成一句话会把排查引向错误的方向。
|
|
152
|
+
if (!fetched || typeof fetched !== "object") {
|
|
149
153
|
timings.fetch = Date.now() - fetchStartedAt;
|
|
150
|
-
return timedResult({ ok: false, stage: "fetch", fatal: false, message:
|
|
154
|
+
return timedResult({ ok: false, stage: "fetch", fatal: false, message: "未收到可用的获取结果:子代理没有返回结构化结果(可能未调用 structured_output,或子代理运行失败);可重试,或手动提供正文文本后重跑" });
|
|
155
|
+
}
|
|
156
|
+
if (!fetched.saved) {
|
|
157
|
+
timings.fetch = Date.now() - fetchStartedAt;
|
|
158
|
+
return timedResult({ ok: false, stage: "fetch", fatal: false, message: fetched.message || "获取失败(可降级:检查输入或手动提供文本)" });
|
|
151
159
|
}
|
|
152
160
|
// 先校验完整计划,按行排序、裁掉重复覆盖并补齐缺口,再合并相邻块。
|
|
153
161
|
// 块数上限约束的是子代理数量,不能通过丢掉尾部原文来实现。
|
|
@@ -382,7 +390,7 @@ const draftPrompt = [
|
|
|
382
390
|
].concat(fm, [
|
|
383
391
|
"# 《" + finalTitle + "》深度精读笔记", "",
|
|
384
392
|
"> 一句话核心概括。", "",
|
|
385
|
-
"## 1.
|
|
393
|
+
"## 1. 概述(主题/背景/核心问题/总体结论,篇幅与整篇笔记相协调)", "",
|
|
386
394
|
"## 2. 结构拆解(按主题组织,含详细要点;关键结论标注原文出处)", "",
|
|
387
395
|
"## 3. 关键概念与术语表(表格)", "",
|
|
388
396
|
"## 4. 关键引用(仅关键结论" + (requireCitations ? ",必须标注页码/章节/段落" : "") + ")",
|
|
@@ -391,6 +399,7 @@ const draftPrompt = [
|
|
|
391
399
|
"---",
|
|
392
400
|
"*笔记整理于 " + today + "*", "",
|
|
393
401
|
"硬性要求:总篇幅≥" + minWords + "字;语言与原文一致;术语统一;引用必须真实;视频" + (includeTimestamps ? "标注时间戳" : "不标注时间戳") + "。",
|
|
402
|
+
lengthMode === "concise" ? "简洁模式:在满足最低篇幅、关键内容和引文要求的前提下尽量接近最低篇幅;不要为凑长度重复或添加无原文依据的内容。" : "",
|
|
394
403
|
"输出前自检:1)覆盖所有块 2)frontmatter完整 3)各小节齐全 4)引用真实 5)篇幅达标 6)语言一致。",
|
|
395
404
|
"",
|
|
396
405
|
"各块精读结果:",
|
|
@@ -598,10 +607,43 @@ if (!sourceComplete) {
|
|
|
598
607
|
.filter(function (line) { return line.trim() !== sourceNotice; }).join("\n").replace(/^\s*\n/, "");
|
|
599
608
|
verified = prefix + sourceNotice + "\n\n" + body;
|
|
600
609
|
}
|
|
610
|
+
if (!passed) {
|
|
611
|
+
// Keep the quality result with the saved note, including when the main
|
|
612
|
+
// agent's chat response is no longer available. A malformed draft is kept
|
|
613
|
+
// verbatim after the notice; only the known template status is changed.
|
|
614
|
+
const front = verified.match(/^\s*---[ \t]*\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/);
|
|
615
|
+
let prefix = front ? front[0] : "";
|
|
616
|
+
let body = front ? verified.slice(front[0].length).replace(/^\r?\n/, "") : verified;
|
|
617
|
+
if (front && fmProfile !== "minimal" && (prefix.match(/^status:[^\r\n]*/gm) || []).length === 1) {
|
|
618
|
+
prefix = prefix.replace(/^(status:[ \t]*)(?:"已完成"|'已完成'|已完成)([ \t]*(?:#[^\r\n]*)?)(\r?)$/m, "$1待核验$2$3");
|
|
619
|
+
}
|
|
620
|
+
// The existing video-source disclosure must remain first and appear once.
|
|
621
|
+
let sourcePrefix = "";
|
|
622
|
+
if (!sourceComplete && body.indexOf(sourceNotice) === 0) {
|
|
623
|
+
sourcePrefix = sourceNotice + "\n\n";
|
|
624
|
+
body = body.slice(sourceNotice.length).replace(/^\r?\n\r?\n/, "");
|
|
625
|
+
}
|
|
626
|
+
function displayIssue(value) {
|
|
627
|
+
let line = value.replace(/[\u0000-\u001f\u007f\u2028\u2029]+/g, " ").replace(/\s+/g, " ").trim();
|
|
628
|
+
if (line.length > 240) line = line.slice(0, 240) + "…";
|
|
629
|
+
// Issues may be supplied by a model: keep them inside the blockquote and
|
|
630
|
+
// render markup as text rather than allowing injected headings or HTML.
|
|
631
|
+
return line.replace(/([\\`*_[\]{}<>!#])/g, "\\$1");
|
|
632
|
+
}
|
|
633
|
+
const visibleIssues = issues.filter(function (issue) { return typeof issue === "string" && issue.trim(); });
|
|
634
|
+
const notice = ["> **质量提示:本笔记未通过检查,请对照原文复核。**"];
|
|
635
|
+
if (failedChunkIds.length) notice.push("> 未成功精读的分块:" + failedChunkIds.join("、") + "。");
|
|
636
|
+
if (visibleIssues.length) {
|
|
637
|
+
notice.push(">", "> 需要复核:");
|
|
638
|
+
visibleIssues.slice(0, 5).forEach(function (issue) { notice.push("> - " + displayIssue(issue)); });
|
|
639
|
+
if (visibleIssues.length > 5) notice.push("> - 另有 " + (visibleIssues.length - 5) + " 项,请查看本次精读结果中的完整问题列表。");
|
|
640
|
+
} else notice.push("> 请查看本次精读结果中的质量详情。");
|
|
641
|
+
verified = (prefix ? prefix.replace(/[\r\n]+$/, "") + "\n\n" : "") + sourcePrefix + notice.join("\n") + "\n\n" + body;
|
|
642
|
+
}
|
|
601
643
|
timings.quality = Date.now() - qualityStartedAt;
|
|
602
644
|
return timedResult({
|
|
603
645
|
ok: true, kind: kind, title: finalTitle,
|
|
604
|
-
filePath: mdPath, chunksCount: chunkPlan.length, fastMode: fastMode,
|
|
646
|
+
filePath: mdPath, chunksCount: chunkPlan.length, lengthMode: lengthMode, minWords: minWords, fastMode: fastMode,
|
|
605
647
|
qualityPassed: passed, qualityIssues: issues,
|
|
606
648
|
qualityChecks: qualityChecks, qualityEvidence: qualityEvidence,
|
|
607
649
|
failedChunks: failedChunks,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deep-read-summarize",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.6.4",
|
|
4
|
+
"description": "DSH 精读插件:书籍精读、论文精读、视频总结、网页摘要 → 结构化 Markdown 读书笔记(YAML frontmatter,可放进 Obsidian / Logseq)。English: deep reading & summarization for DSH — books, papers, videos and web pages into structured Markdown notes.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"exports": {
|
|
@@ -58,7 +58,11 @@
|
|
|
58
58
|
"llm",
|
|
59
59
|
"subagent",
|
|
60
60
|
"mapreduce",
|
|
61
|
-
"parsers"
|
|
61
|
+
"parsers",
|
|
62
|
+
"精读",
|
|
63
|
+
"读书笔记",
|
|
64
|
+
"论文精读",
|
|
65
|
+
"视频总结"
|
|
62
66
|
],
|
|
63
67
|
"license": "MIT",
|
|
64
68
|
"publishConfig": {
|
package/parsers/_prompt.js
CHANGED
|
@@ -38,7 +38,8 @@ function buildFetchPrompt(cfg) {
|
|
|
38
38
|
opts.chunkBalanceScriptPath ? "保存文件后,运行 Node 脚本计算真实文本各行的字符数分块边界:脚本路径 " + JSON.stringify(opts.chunkBalanceScriptPath) + ",源文件路径 " + JSON.stringify(tempFile) + ",分块数上限 " + maxChunks + "。路径是 JSON 字符串数据,须按当前 shell 正确引用,不能作为命令解释;参数顺序为 node <脚本路径> <源文件路径> <分块数上限>。将工具输出的 JSON 对象原样放入输出的 balancePlan 字段;不要估算、编造或改写。如工具不可用或失败,省略 balancePlan 并继续。" : "",
|
|
39
39
|
"输出 JSON:",
|
|
40
40
|
cfg.jsonExample,
|
|
41
|
-
"若无法获取文本输出 { \"saved\": false, \"message\": \"原因\" }
|
|
41
|
+
"若无法获取文本输出 { \"saved\": false, \"message\": \"原因\" }。",
|
|
42
|
+
"结果用结构化输出工具提交,不要把 JSON 只写在正文里;totalLines 与 startLine/endLine 必须填本次实际行号(示例数字仅示意,照抄会截断原文),metadata.language 取 zh / en / other / 空字符串之一。"
|
|
42
43
|
]).join("\n");
|
|
43
44
|
}
|
|
44
45
|
|
package/parsers/book.js
CHANGED
|
@@ -25,7 +25,7 @@ module.exports = {
|
|
|
25
25
|
"识别书籍结构:目录/序言/各章节标题及其行号范围。"
|
|
26
26
|
],
|
|
27
27
|
chunkRule: "章节(或章节内小节)",
|
|
28
|
-
jsonExample: '{ "kind": "book", "saved": true, "totalLines":
|
|
28
|
+
jsonExample: '{ "kind": "book", "saved": true, "totalLines": 200, "metadata": { "title": "", "author": "", "year": "", "language": "zh" }, "chunkPlan": [ { "id": 1, "topic": "章节主题", "startLine": 1, "endLine": 200 } ] }'
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
};
|
package/parsers/paper.js
CHANGED
|
@@ -24,7 +24,7 @@ module.exports = {
|
|
|
24
24
|
"识别论文结构:Abstract/Introduction/Methods/Results/Discussion/Conclusion/Appendix 及各表图行号范围。"
|
|
25
25
|
],
|
|
26
26
|
chunkRule: "论文章节",
|
|
27
|
-
jsonExample: '{ "kind": "paper", "saved": true, "totalLines":
|
|
27
|
+
jsonExample: '{ "kind": "paper", "saved": true, "totalLines": 200, "metadata": { "title": "", "author": "", "year": "", "language": "zh" }, "chunkPlan": [ { "id": 1, "topic": "Introduction", "startLine": 1, "endLine": 200 } ] }'
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
};
|
package/parsers/video.js
CHANGED
|
@@ -42,8 +42,8 @@ module.exports = {
|
|
|
42
42
|
let pageValue = pageMatch ? pageMatch[1] : '';
|
|
43
43
|
try { pageValue = decodeURIComponent(pageValue); } catch (error) { pageValue = 'invalid'; }
|
|
44
44
|
if (pageMatch && (!/^[1-9]\d*$/.test(pageValue) || !Number.isSafeInteger(Number(pageValue)))) {
|
|
45
|
-
return 'B站输入的 p 分P参数非法,必须是从 1
|
|
46
|
-
JSON.stringify({ saved: false, message: 'B站 p 分P参数非法,请指定有效的正整数分P编号' });
|
|
45
|
+
return 'B站输入的 p 分P参数非法,必须是从 1 开始的整数。不要获取字幕或音频,也不要转写。按 ' +
|
|
46
|
+
JSON.stringify({ saved: false, message: 'B站 p 分P参数非法,请指定有效的正整数分P编号' }) + ' 提交结构化结果。';
|
|
47
47
|
}
|
|
48
48
|
const requestedPage = pageMatch ? Number(pageValue) : null;
|
|
49
49
|
const scriptPath = typeof o.transcribeScriptPath === 'string' && o.transcribeScriptPath ? o.transcribeScriptPath : '';
|
|
@@ -65,7 +65,7 @@ module.exports = {
|
|
|
65
65
|
: "已安装时用 yt-dlp 抓字幕(CC)转文本;无 CC 则降级(转写已禁用)。";
|
|
66
66
|
|
|
67
67
|
const steps = [
|
|
68
|
-
"记录文本来源(metadata.textSource):subtitle(平台字幕)/ transcription(本地转写)/ desc(仅简介,作为降级/背景)/ manual
|
|
68
|
+
"记录文本来源(metadata.textSource):subtitle(平台字幕)/ transcription(本地转写)/ desc(仅简介,作为降级/背景)/ manual(用户提供)。必须如实反映本次实际拿到的来源,不要照抄示例值;无法确认时省略该字段(按来源不完整处理)。",
|
|
69
69
|
includeTimestamps
|
|
70
70
|
? "保留真实时间定位:B站字幕保留每条 from/to,YouTube CC 保留每条 cue 的 start/end;转成文本时每段独占一行,格式为 [HH:MM:SS.mmm --> HH:MM:SS.mmm] 原文。写入目标文件时保留这些时间,不可把全文压成一行。简介/人工文案若没有真实时间信息,明确注明无法提供时间戳,禁止猜测或编造。"
|
|
71
71
|
: "字幕或转写按原有分段逐段换行写入目标文件,保留内容结构,不要把全文压成一行;本次不要求在正文标时间戳。",
|
|
@@ -108,7 +108,7 @@ module.exports = {
|
|
|
108
108
|
kindLabel: "视频(video)",
|
|
109
109
|
steps: steps,
|
|
110
110
|
chunkRule: "主题脉络(而非时间)",
|
|
111
|
-
jsonExample: '{ "kind": "video", "saved": true, "totalLines":
|
|
111
|
+
jsonExample: '{ "kind": "video", "saved": true, "totalLines": 200, "metadata": { "title": "", "author": "", "year": "", "language": "zh", "textSource": "subtitle" }, "chunkPlan": [ { "id": 1, "topic": "主题段", "startLine": 1, "endLine": 200 } ] }'
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
};
|
package/parsers/web.js
CHANGED
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
|
23
23
|
"正文写入目标文件(不截断、不加评注),用 read 确认总行数。"
|
|
24
24
|
],
|
|
25
25
|
chunkRule: "逻辑主题",
|
|
26
|
-
jsonExample: '{ "kind": "web", "saved": true, "totalLines":
|
|
26
|
+
jsonExample: '{ "kind": "web", "saved": true, "totalLines": 200, "metadata": { "title": "", "author": "", "year": "", "language": "zh" }, "chunkPlan": [ { "id": 1, "topic": "主题", "startLine": 1, "endLine": 200 } ] }'
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
};
|
|
@@ -23,10 +23,12 @@ whenToUse: 用户提供一本书、论文(arXiv/PDF)、视频链接(YouTub
|
|
|
23
23
|
## 输入
|
|
24
24
|
|
|
25
25
|
用户提供:内容链接或本地文件路径。
|
|
26
|
-
可选参数:`type`(auto/book/paper/video/web)、`options`(minWords / fastMode / maxChunks / readConcurrency / parallelQuality / readCache / readCacheIdentity / maxRetries / requireCitations / includeTimestamps / transcribe / whisperModel / language / device / cpuThreads / transcriptCache / outputDir / tempDir / frontmatter)。
|
|
26
|
+
可选参数:`type`(auto/book/paper/video/web)、`options`(lengthMode / minWords / fastMode / maxChunks / readConcurrency / parallelQuality / readCache / readCacheIdentity / maxRetries / requireCitations / includeTimestamps / transcribe / whisperModel / language / device / cpuThreads / transcriptCache / outputDir / tempDir / frontmatter)。
|
|
27
27
|
|
|
28
28
|
优先调用插件提供的 `deep_read_summarize` 工具,参数为 `{ input, type, options }`。如果当前宿主没有这个工具,按技能末尾提供的 meta / script / args 调用 `workflow` 工具。两种入口执行相同的获取、精读与质量核验。
|
|
29
29
|
|
|
30
|
+
如果用户明确要求“简洁笔记”或“简短精读”,可使用 `options: { "lengthMode": "concise" }`。它默认使用 `minWords: 500` 和 `fastMode: true`,并要求成稿避免无依据的扩写;原文和引文核验仍会执行。用户明确给出的设置优先:单独传入 `minWords` 可覆盖最低篇幅,要保留第 5–7 节则传入 `fastMode: false`。选择模式时不要照抄下方默认示例中的 `minWords: 2500` 或 `fastMode: false`,除非用户明确要求。`minWords` 是最低计数而不是字数上限,不能承诺输出恰好或不超过某个字数。
|
|
31
|
+
|
|
30
32
|
`options.frontmatter` 决定 frontmatter 用哪套键(默认 `obsidian`,与历史行为一致):
|
|
31
33
|
- `obsidian`:title / aliases / author / year / type / url / tags / created / status —— 配 Dataview 用这套
|
|
32
34
|
- `generic`:把 Hugo 的保留键换掉(`type` → `docType`、`url` → `sourceUrl`、`created` → `date`),可直接放进 Hugo / Jekyll
|
|
@@ -50,7 +52,7 @@ whenToUse: 用户提供一本书、论文(arXiv/PDF)、视频链接(YouTub
|
|
|
50
52
|
|
|
51
53
|
## 输出
|
|
52
54
|
|
|
53
|
-
精读工具返回 `{ ok, filePath, note, qualityPassed, qualityIssues, qualityChecks, qualityEvidence, failedChunks, coverageComplete, sourceComplete, textSource, timings, readTimings }`;可选 `draftContext` 记录成稿或修订稿的提取方式(`stage`、`kind`)及笔记前后额外文字(`before`、`after`),`kind` 为 `fenced` 或 `preamble
|
|
55
|
+
精读工具返回 `{ ok, filePath, note, lengthMode, minWords, fastMode, qualityPassed, qualityIssues, qualityChecks, qualityEvidence, failedChunks, coverageComplete, sourceComplete, textSource, timings, readTimings }`;可选 `draftContext` 记录成稿或修订稿的提取方式(`stage`、`kind`)及笔记前后额外文字(`before`、`after`),`kind` 为 `fenced` 或 `preamble`。质量未通过时,`note` 开头保留提示和最多 5 项问题;obsidian/generic 模板中可安全识别的 `status: 已完成` 会改为 `status: 待核验`。其余问题仍在 `qualityIssues` 中。`coverageComplete: false` 表示缺少有效总行数,无法确认尾部覆盖;`sourceComplete: false` 表示视频仅有简介或来源未确认,笔记会保留来源限制且质量降级。来源完整性仍依据获取代理声明,不能当作视频真实内容已全部证明。`timings` 提供 detect/fetch/read/draft/quality/total 毫秒耗时;`readTimings` 提供精读块的行号、毫秒耗时、成功状态及缓存命中状态,不能由此推测未提供的 token 用量。
|
|
54
56
|
|
|
55
57
|
> ⚠️ **`note` 就是完整笔记正文,`filePath` 只是建议路径**:脚本运行在无文件系统的沙箱里(DSH 的 workflow 契约:脚本只负责协调子代理),**它不会替你写文件**。必须由你(主代理)在拿到结果后用 `write` 工具把它写到 `filePath`——默认 `./output/`,可用 `options.outputDir` 指向 Obsidian 仓库或静态站点的内容目录。
|
|
56
58
|
|