deep-read-summarize 0.6.0 → 0.6.2

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.
@@ -376,7 +376,7 @@ if (fmProfile === "obsidian") {
376
376
  fm.push("---");
377
377
 
378
378
  const draftPrompt = [
379
- "将以下多块精读结果整合为完整的结构化精读笔记,只输出标准 Markdown(含 YAML frontmatter)。",
379
+ "将以下多块精读结果整合为完整的结构化精读笔记,只输出标准 Markdown(含 YAML frontmatter),不要前言、结尾说明或包裹整篇笔记的代码围栏;笔记内部需要的代码块可保留。",
380
380
  sourceComplete ? "来源完整性仍需由独立原文核验确认。" : "本次来源不完整。必须在正文开头保留以下可见来源限制,不得称为完整视频精读或补写未取得的视频内容:\n" + sourceNotice,
381
381
  "模板:"
382
382
  ].concat(fm, [
@@ -410,7 +410,10 @@ if (typeof draft !== "string" || !draft.trim()) return timedResult({ ok: false,
410
410
  // ---------- 5. 程序检查 + 独立原文核验 ----------
411
411
  phase("质量校验");
412
412
  const qualityStartedAt = Date.now();
413
- let verified = draft;
413
+ const extractedDraft = __quality.extractNote(draft);
414
+ let verified = extractedDraft.note;
415
+ const draftContext = [];
416
+ if (extractedDraft.context) draftContext.push(Object.assign({ stage: "draft" }, extractedDraft.context));
414
417
  let passed = false;
415
418
  let issues = [];
416
419
  let qualityChecks = {};
@@ -560,7 +563,7 @@ for (let round = 0; round <= maxRetries; round++) {
560
563
  if (!repairableSource) break;
561
564
  if (round < maxRetries) {
562
565
  const fixPrompt = [
563
- "修正以下笔记以解决校验问题,输出完整修正版:",
566
+ "修正以下笔记以解决校验问题,只输出完整修正版 Markdown,不要前言、结尾说明或包裹整篇笔记的代码围栏:",
564
567
  issues.map(function (s) { return "- " + s; }).join("\n"),
565
568
  "原文路径和覆盖证据(必要时用 read 核对,不能臆造缺口):", JSON.stringify(sourceContext),
566
569
  "必须保留的 frontmatter 模板:", fm.join("\n"),
@@ -575,11 +578,13 @@ for (let round = 0; round <= maxRetries; round++) {
575
578
  if (typeof repaired !== "string" || !repaired.trim()) {
576
579
  issues.push("修正结果为空或不是字符串,已保留上一份有效笔记"); break;
577
580
  }
578
- const repairedStructure = __quality.checkNoteStructure(repaired, structureOptions);
581
+ const extractedRepair = __quality.extractNote(repaired);
582
+ const repairedStructure = __quality.checkNoteStructure(extractedRepair.note, structureOptions);
579
583
  if (!repairedStructure.formatComplete || (localCheck.lengthMet && !repairedStructure.lengthMet)) {
580
584
  issues.push("修正结果格式不完整或篇幅退化,已保留上一份有效笔记"); break;
581
585
  }
582
- verified = repaired;
586
+ verified = extractedRepair.note;
587
+ if (extractedRepair.context) draftContext.push(Object.assign({ stage: "repair" }, extractedRepair.context));
583
588
  }
584
589
  }
585
590
 
@@ -603,6 +608,7 @@ return timedResult({
603
608
  coverageComplete: coverageComplete,
604
609
  textSource: textSource,
605
610
  sourceComplete: sourceComplete,
611
+ ...(draftContext.length ? { draftContext: draftContext } : {}),
606
612
  note: verified,
607
- __cacheReads: cacheResume ? reads : undefined
613
+ ...(cacheResume ? { __cacheReads: reads } : {})
608
614
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deep-read-summarize",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Deep reading & summarization for DSH: books/papers/videos/web → structured Markdown notes with YAML frontmatter. Plugin parsers, MapReduce deep-read, JSON Schema-constrained sub-tasks.",
5
5
  "type": "commonjs",
6
6
  "main": "index.js",
@@ -44,13 +44,13 @@ whenToUse: 用户提供一本书、论文(arXiv/PDF)、视频链接(YouTub
44
44
  6. **波次3 合并成稿**:整合为完整笔记(Reduce),内嵌质量自检
45
45
  7. **质量校验**:程序检查 frontmatter 模板、必要章节和篇幅;核验代理必须读取本次原文,逐块提供摘录、对第 4 节逐字引用提供原句与行号。`parallelQuality: true` 时多分块由独立代理并行核验各块及全部显式引文,另由代理检查全局术语与语言一致性;默认沿用原核验路径,`readConcurrency` 同时限制并行核验并发。不得只看笔记或仅返回 pass。`qualityEvidence` 可供回查;核验失败必须如实报告。`maxRetries` 为 0–3,修订失败、空结果或结构退化时保留上一份有效成稿。缺总行数、精读失败、仅简介或未知视频来源等问题不能靠改写笔记消除,不进行徒劳全文修订
46
46
  8. **落盘(必须,别跳过)**:精读工具只返回 `note`(笔记正文)与 `filePath`(建议路径)——**脚本本身没有文件系统权限**。拿到结果后要用 `write` 工具把 `note` 原样写入 `filePath`(目录不存在就先创建);不写就等于笔记丢了,用户只会看到一段返回文本
47
- 9. **如实交代结果**:`ok: false` 要说明卡在哪一步(`stage`)和原因,别拿半成品冒充成品;`qualityPassed: false`、`qualityIssues` 非空、或 `failedChunks > 0`(有块精读失败、笔记存在缺口)时,必须在回复里点出来
47
+ 9. **如实交代结果**:`ok: false` 要说明卡在哪一步(`stage`)和原因,别拿半成品冒充成品;`qualityPassed: false`、`qualityIssues` 非空、或 `failedChunks > 0`(有块精读失败、笔记存在缺口)时,必须在回复里点出来。若 `draftContext` 中 `before` 或 `after` 非空,向用户说明其中保留的成稿额外文字;这些文字未通过原文核验,不要把它当成已核验的笔记内容
48
48
 
49
49
  跨次精读缓存默认关闭,仅插件工具入口支持;启用 `readCache` 时必须填写 `readCacheIdentity`(供应商、固定模型版本及输出相关设置)。身份由调用者保证,变更时必须更换;缓存明文保存在 `tempDir/.read-cache-v1`,可能包含原文摘录,命中后仍独立核验原文。
50
50
 
51
51
  ## 输出
52
52
 
53
- 精读工具返回 `{ ok, filePath, note, qualityPassed, qualityIssues, qualityChecks, qualityEvidence, failedChunks, coverageComplete, sourceComplete, textSource, timings, readTimings }`。`coverageComplete: false` 表示缺少有效总行数,无法确认尾部覆盖;`sourceComplete: false` 表示视频仅有简介或来源未确认,笔记会保留来源限制且质量降级。来源完整性仍依据获取代理声明,不能当作视频真实内容已全部证明。`timings` 提供 detect/fetch/read/draft/quality/total 毫秒耗时;`readTimings` 提供精读块的行号、毫秒耗时、成功状态及缓存命中状态,不能由此推测未提供的 token 用量。
53
+ 精读工具返回 `{ ok, filePath, note, qualityPassed, qualityIssues, qualityChecks, qualityEvidence, failedChunks, coverageComplete, sourceComplete, textSource, timings, readTimings }`;可选 `draftContext` 记录成稿或修订稿的提取方式(`stage`、`kind`)及笔记前后额外文字(`before`、`after`),`kind` 为 `fenced` 或 `preamble`。`coverageComplete: false` 表示缺少有效总行数,无法确认尾部覆盖;`sourceComplete: false` 表示视频仅有简介或来源未确认,笔记会保留来源限制且质量降级。来源完整性仍依据获取代理声明,不能当作视频真实内容已全部证明。`timings` 提供 detect/fetch/read/draft/quality/total 毫秒耗时;`readTimings` 提供精读块的行号、毫秒耗时、成功状态及缓存命中状态,不能由此推测未提供的 token 用量。
54
54
 
55
55
  > ⚠️ **`note` 就是完整笔记正文,`filePath` 只是建议路径**:脚本运行在无文件系统的沙箱里(DSH 的 workflow 契约:脚本只负责协调子代理),**它不会替你写文件**。必须由你(主代理)在拿到结果后用 `write` 工具把它写到 `filePath`——默认 `./output/`,可用 `options.outputDir` 指向 Obsidian 仓库或静态站点的内容目录。
56
56
 
package/workflow.js CHANGED
@@ -80,7 +80,8 @@ function buildSelfContainedScript(parserRegistry = parsers.registry) {
80
80
  const runtimePaths = { transcribeScript: fs.realpathSync(path.join(__dirname, 'scripts', 'transcribe.js')), chunkBalanceScript: fs.realpathSync(path.join(__dirname, 'scripts', 'chunk-balance.js')) };
81
81
  return 'const __runtimePaths = ' + JSON.stringify(runtimePaths) + ';\n' +
82
82
  'const normalizeWorkflowOptions = ' + normalizeWorkflowOptions.toString() + ';\n' +
83
- 'const __quality = { checkNoteStructure: ' + quality.checkNoteStructure.toString() +
83
+ 'const __quality = { extractNote: ' + quality.extractNote.toString() +
84
+ ', checkNoteStructure: ' + quality.checkNoteStructure.toString() +
84
85
  ', validateSourceCheck: ' + quality.validateSourceCheck.toString() + ' };\n' +
85
86
  RAW_SCRIPT.replace(marker, impl + "\nconst parsers = args._parsers || __parsers;");
86
87
  }