deep-read-summarize 0.3.6 → 0.3.9
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 +97 -1
- package/README.en.md +314 -0
- package/README.md +41 -14
- package/cordis.patch.yml +14 -7
- package/docs/RELEASE.md +44 -7
- package/index.js +64 -8
- package/package.json +7 -5
- package/parsers/book.js +1 -1
- package/parsers/video.js +54 -18
- package/schemas/index.js +9 -2
- package/scripts/transcribe.js +306 -0
- package/skills/deep-read-summarize/SKILL.md +15 -9
- package/tests/index.test.js +319 -1
- package/tests/run-tests.js +166 -0
- package/workflow.js +89 -76
- package/scripts/transcribe.ps1 +0 -68
package/docs/RELEASE.md
CHANGED
|
@@ -32,18 +32,55 @@
|
|
|
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 → 在 GitHub Release 被发布时自动发布
|
|
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 并推送
|
|
50
|
+
git tag -a vX.Y.Z -m "vX.Y.Z" && git push origin vX.Y.Z
|
|
51
|
+
|
|
52
|
+
# 3. 建 Release —— 这一步触发 publish.yml
|
|
53
|
+
gh release create vX.Y.Z --title "vX.Y.Z" --notes-file <notes 文件>
|
|
54
|
+
|
|
55
|
+
# 4. 验证线上
|
|
56
|
+
npm view deep-read-summarize --prefer-online
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**前置(每个包一次性,只能在网页上配)**:
|
|
60
|
+
`https://www.npmjs.com/package/<包名>/access` → Trusted Publishers → Add,填
|
|
61
|
+
Provider `GitHub Actions` / Organization or user `PensiveFei` / Repository `deep-read-summarize` /
|
|
62
|
+
Workflow filename `publish.yml` / Environment 留空。
|
|
63
|
+
|
|
64
|
+
**历史 tag 里没有这个 workflow 时**(workflow 定义从 main 取,包内容从 tag 取):
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
gh workflow run publish.yml --ref main -f publish_ref=refs/tags/vX.Y.Z
|
|
68
|
+
gh run watch
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 回退:本地发布(需要交互式 2FA)
|
|
72
|
+
|
|
73
|
+
> ⚠️ 2026-07 起 npm 已限制「绕过 2FA 的 granular access token」用于**直接发布**,
|
|
74
|
+
> 所以本地发布只能靠交互式 OTP —— 不再有「建个长期 token 一劳永逸」这条路。
|
|
36
75
|
|
|
37
76
|
```bash
|
|
38
77
|
cd <项目目录>
|
|
39
|
-
npm run lint && npm test && npm run validate # 先本地全绿
|
|
40
|
-
npm
|
|
41
|
-
npm
|
|
42
|
-
npm view deep-read-summarize --prefer-online # 验证线上(注意:发布后首次查询可能 404,索引有延迟)
|
|
78
|
+
npm run lint && npm test && npm run test:node && npm run validate # 先本地全绿
|
|
79
|
+
npm publish --otp=<6位码> # prepublishOnly 自动跑门禁
|
|
80
|
+
npm view deep-read-summarize --prefer-online # 验证线上(首次查询可能索引延迟)
|
|
43
81
|
```
|
|
44
82
|
|
|
45
|
-
-
|
|
46
|
-
- 本沙箱环境 npm 默认缓存目录可能被拒(EPERM),用 npm publish --cache <工作区内目录>
|
|
83
|
+
- 本沙箱环境 npm 默认缓存目录可能被拒(EPERM),用 `npm publish --cache <可写目录>`
|
|
47
84
|
- 版本号:功能增强 → minor(0.x → 0.y);修复 → patch;不兼容 → major
|
|
48
85
|
|
|
49
86
|
## 当前版本速览
|
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
|
|
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,28 +87,30 @@ 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
|
}
|
|
49
101
|
|
|
50
|
-
/**
|
|
102
|
+
/** Cordis 插件入口:注册运行时技能,使模型可直接执行精读 workflow。 */
|
|
51
103
|
function apply(ctx, config = {}) {
|
|
52
104
|
const skillDir = path.join(__dirname, 'skills', 'deep-read-summarize');
|
|
53
105
|
return ctx.skills.register({
|
|
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
|
-
source
|
|
111
|
+
// source 是技能的「来源桶」(runtime / bundled / user-dsh …),不是自由描述:
|
|
112
|
+
// 本技能随插件包分发,因此登记为 bundled。
|
|
113
|
+
source: 'bundled'
|
|
60
114
|
});
|
|
61
115
|
}
|
|
62
116
|
|
|
@@ -71,3 +125,5 @@ module.exports.workflow = workflow;
|
|
|
71
125
|
module.exports.parsers = parsers;
|
|
72
126
|
module.exports.schemas = schemas;
|
|
73
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.9",
|
|
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": [
|
|
@@ -20,7 +21,8 @@
|
|
|
20
21
|
"skills",
|
|
21
22
|
"scripts",
|
|
22
23
|
"tests",
|
|
23
|
-
"docs",
|
|
24
|
+
"docs/RELEASE.md",
|
|
25
|
+
"docs/RELEASE-v0.1.0.md",
|
|
24
26
|
"cordis.patch.yml",
|
|
25
27
|
"CHANGELOG.md",
|
|
26
28
|
"README.md",
|
|
@@ -33,8 +35,8 @@
|
|
|
33
35
|
"lint": "node scripts/lint.js",
|
|
34
36
|
"validate": "node tests/quick_validate.js && node scripts/security-check.js",
|
|
35
37
|
"security": "node scripts/security-check.js",
|
|
36
|
-
"test:node": "node --test
|
|
37
|
-
"prepublishOnly": "node tests/run-tests.js && node scripts/lint.js && node scripts/security-check.js"
|
|
38
|
+
"test:node": "node --test",
|
|
39
|
+
"prepublishOnly": "node tests/run-tests.js && node --test && node scripts/lint.js && node scripts/security-check.js"
|
|
38
40
|
},
|
|
39
41
|
"dsh": {
|
|
40
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
|
],
|
package/parsers/video.js
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
// ② 无公开字幕 → 用插件自带转写(faster-whisper small/int8/VAD,镜像+缓存)得到全文
|
|
7
7
|
// ③ 都不行 → 降级(提示人工提供转写文本,或退回 desc 作背景)。
|
|
8
8
|
// 本机/用户使用一致:只依赖环境变量 + 相对/标准路径,不写死本机绝对路径。
|
|
9
|
+
// 跨平台:Windows / macOS / Linux 同等支持。转写脚本是 Node 写的(scripts/transcribe.js),
|
|
10
|
+
// 三平台**命令行完全一致**;平台差异只在「脚本定位命令」与「yt-dlp 安装方式」上,
|
|
11
|
+
// 两套写法都在提示词里给出,由执行代理按自己的系统选择。
|
|
12
|
+
// ⚠️ 本提示词会被内联进 workflow 沙箱脚本执行,沙箱**不提供 process / require**,
|
|
13
|
+
// 所以这里不能按平台做分支(写了 process.platform 会直接被回归测试拦下),
|
|
14
|
+
// 只能把各平台的写法都列出来。详见 tests/run-tests.js 的沙箱 API 断言。
|
|
9
15
|
// 提示词骨架复用 parsers/_prompt.js,此处只提供差异化配置。
|
|
10
16
|
// ============================================================================
|
|
11
17
|
|
|
@@ -14,36 +20,66 @@ const prompt = require("./_prompt");
|
|
|
14
20
|
module.exports = {
|
|
15
21
|
name: "video",
|
|
16
22
|
types: ["video"],
|
|
17
|
-
description: "视频解析器(B站/抖音/YouTube →
|
|
23
|
+
description: "视频解析器(B站/抖音/YouTube → 完整逐字稿,字幕优先,无字幕自动转写;Windows/macOS/Linux)",
|
|
18
24
|
|
|
19
25
|
buildPrompt: function (input, opts) {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
26
|
+
const o = opts || {};
|
|
27
|
+
const tempDir = o.tempDir || "./.tmp";
|
|
28
|
+
// 默认 true:无字幕时自动走本地转写。false 时必须真的改变提示词——
|
|
29
|
+
// 此前这里算出来的值从未被使用,transcribe:false 与 true 生成的提示词逐字相同。
|
|
30
|
+
const wantTranscribe = o.transcribe !== false;
|
|
31
|
+
const whisperModel = o.whisperModel || "small";
|
|
32
|
+
const language = o.language || "zh";
|
|
33
|
+
const device = o.device || "cpu";
|
|
22
34
|
const degradeMsg = "需要人工提供转写文本或视频文案";
|
|
35
|
+
|
|
36
|
+
const noSubtitleBranch = wantTranscribe
|
|
37
|
+
? "② 若**无公开字幕**,用插件自带 faster-whisper 转写得到全文;③ 仍不可行才降级(提示人工提供转写文本 或 退回 desc 作背景)。"
|
|
38
|
+
: "② **本次已禁用转写**(options.transcribe=false):无公开字幕时直接降级(提示人工提供转写文本 或 退回 desc 作背景),不要尝试转写。";
|
|
39
|
+
const biliNoSubtitle = wantTranscribe
|
|
40
|
+
? " 3) 无公开字幕时(textSource=transcription):按下方「转写执行」用 faster-whisper 转写整段音频,得到完整全文。"
|
|
41
|
+
: " 3) 无公开字幕时:转写已被禁用(options.transcribe=false),按降级处理,不要取音频、不要转写。";
|
|
42
|
+
const douyinTail = wantTranscribe
|
|
43
|
+
? "desc 较完整时可直接作为文本(textSource=desc);若 desc 太短,仍按下方「转写执行」转写(textSource=transcription)。"
|
|
44
|
+
: "desc 较完整时可直接作为文本(textSource=desc);若 desc 太短,直接降级提示用户补充文案(转写已禁用)。";
|
|
45
|
+
const ytTail = wantTranscribe
|
|
46
|
+
? "已安装时用 yt-dlp 抓字幕(CC)转文本;无 CC 则转写。"
|
|
47
|
+
: "已安装时用 yt-dlp 抓字幕(CC)转文本;无 CC 则降级(转写已禁用)。";
|
|
48
|
+
|
|
23
49
|
const steps = [
|
|
24
50
|
"记录文本来源(metadata.textSource):subtitle(平台字幕)/ transcription(本地转写)/ desc(仅简介,作为降级/背景)/ manual(用户提供)。",
|
|
25
|
-
"统一流程:① 先取视频字幕(B站 AI 字幕 / YouTube yt-dlp CC
|
|
26
|
-
"若输入是 B 站链接(bilibili.com / b23.tv,短链先用 curl -L 跟随重定向提取 BV 号):用 curl(Windows
|
|
51
|
+
"统一流程:① 先取视频字幕(B站 AI 字幕 / YouTube yt-dlp CC);" + noSubtitleBranch,
|
|
52
|
+
"若输入是 B 站链接(bilibili.com / b23.tv,短链先用 curl -L 跟随重定向提取 BV 号):用 curl(Windows 10+ 与 macOS/Linux 均自带,零安装)调官方公开 API:\n" +
|
|
27
53
|
" 1) 元数据+简介:curl 'https://api.bilibili.com/x/web-interface/view?bvid=<BV>' → 取 title / desc(简介仅作背景/补充,不满一篇精读)/ owner.name / duration / aid / cid\n" +
|
|
28
54
|
" 2) 字幕(**优先,最快**):curl 'https://api.bilibili.com/x/player/v2?aid=<aid>&cid=<cid>' 取 subtitle 列表;若有则下载转文本(textSource=subtitle)——这已是完整逐字稿,直接使用\n" +
|
|
29
|
-
|
|
55
|
+
biliNoSubtitle,
|
|
30
56
|
|
|
31
|
-
"若输入是抖音链接/分享口令(douyin.com / v.douyin.com):用户分享时复制的文字本身就是该视频的文案(desc)。
|
|
32
|
-
"若输入是 YouTube 等其他平台:先探测是否已装 yt-dlp
|
|
57
|
+
"若输入是抖音链接/分享口令(douyin.com / v.douyin.com):用户分享时复制的文字本身就是该视频的文案(desc)。" + douyinTail,
|
|
58
|
+
"若输入是 YouTube 等其他平台:先探测是否已装 yt-dlp(运行 `yt-dlp --version`)。若未安装:绝对不要去下载 yt-dlp 二进制(GitHub 直连在部分网络下极慢且易中断,会卡死整个流程);**按系统装**——Windows 先试 `winget install yt-dlp.yt-dlp`,macOS 先试 `brew install yt-dlp`,三平台都可再试 `pip install -U yt-dlp -i https://pypi.tuna.tsinghua.edu.cn/simple`;" +
|
|
59
|
+
(wantTranscribe ? "仍不可用则按下方「转写执行」直接转写或降级。" : "仍不可用则直接降级(转写已禁用)。") + ytTail
|
|
60
|
+
];
|
|
33
61
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
62
|
+
if (wantTranscribe) {
|
|
63
|
+
steps.push(
|
|
64
|
+
"转写执行(faster-whisper " + whisperModel + " / int8 / " + language + ",镜像+缓存,保证本机与用户一致):\n" +
|
|
65
|
+
" ① 先取音频:B站用 playurl(curl 'https://api.bilibili.com/x/player/playurl?avid=<aid>&cid=<cid>&fnval=16&fourk=1' 的 dash.audio[0].baseUrl)或 yt-dlp,下载存到 '" + tempDir + "/audio.m4a';\n" +
|
|
66
|
+
" ② 定位插件转写脚本(文件名固定 `transcribe.js`):Windows 用 `Get-ChildItem -Path $env:USERPROFILE/.dsh -Recurse -Filter transcribe.js`;macOS/Linux 用 `find \"$HOME/.dsh\" -name transcribe.js`(也可直接用 glob 搜 *transcribe.js);\n" +
|
|
67
|
+
" ③ 运行(**三平台命令行完全一致**,脚本是 Node 写的,与 pwsh / bash 无关):`node <脚本路径> --audio '" + tempDir + "/audio.m4a' --out '" + tempDir + "/transcript.txt' --device " + device + " --model " + whisperModel + " --language " + language + "`;\n" +
|
|
68
|
+
" ④ 转写可能较慢:用 run_in_background: true 启动后,轮询输出文件 '" + tempDir + "/transcript.txt' 是否写出内容(非空且稳定),或日志出现 DONE;设合理超时,超时/失败则降级;\n" +
|
|
69
|
+
" ⑤ 成功后读取 transcript.txt 作为全文(textSource=transcription)。脚本自举:uv 建 Python 3.12 环境 + 镜像装 faster-whisper + hf-mirror 下模型并缓存;Windows/macOS/Linux 是**同一份实现**。**⚠️ 首次转写会先下载模型(small 约 484MB,hf-mirror,非 GitHub)并较慢——先向用户说明这是正常的一次性下载,勿当成卡死;之后缓存复用、秒开。**\n" +
|
|
70
|
+
" ⑥ 若 `node` 不在 PATH(macOS 从图形界面启动时常见),先用 `command -v node` 确认;确认不可用就直接降级,不要为了跑转写脚本去安装 Node。"
|
|
71
|
+
);
|
|
72
|
+
} else {
|
|
73
|
+
steps.push(
|
|
74
|
+
"【转写已禁用】options.transcribe=false:只允许使用平台字幕或简介(desc)。不要定位或运行 scripts/transcribe.js,不要下载模型,不要安装任何转写工具;拿不到字幕就按降级处理。"
|
|
75
|
+
);
|
|
76
|
+
}
|
|
40
77
|
|
|
41
|
-
|
|
42
|
-
];
|
|
78
|
+
steps.push('若以上均不可用或抓取失败:输出 { "saved": false, "message": "' + degradeMsg + '" }。');
|
|
43
79
|
|
|
44
80
|
return prompt.buildFetchPrompt({
|
|
45
81
|
input: input,
|
|
46
|
-
opts:
|
|
82
|
+
opts: o,
|
|
47
83
|
fetchTarget: "视频完整逐字稿(字幕优先,无字幕自动转写)",
|
|
48
84
|
kindLabel: "视频(video)",
|
|
49
85
|
steps: steps,
|
|
@@ -51,4 +87,4 @@ module.exports = {
|
|
|
51
87
|
jsonExample: '{ "kind": "video", "saved": true, "totalLines": N, "metadata": { "title": "", "author": "", "year": "", "language": "zh|en", "textSource": "subtitle|transcription|desc|manual" }, "chunkPlan": [ { "id": 1, "topic": "主题段", "startLine": 1, "endLine": 200 } ] }'
|
|
52
88
|
});
|
|
53
89
|
}
|
|
54
|
-
};
|
|
90
|
+
};
|
package/schemas/index.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
// ============================================================================
|
|
2
2
|
// JSON Schemas — 结构化输出约束
|
|
3
3
|
// ============================================================================
|
|
4
|
-
//
|
|
5
|
-
//
|
|
4
|
+
// 谁在用哪一份(别凭印象——此前 workflow 脚本里有一份手抄副本,已经漂移):
|
|
5
|
+
// - fetchResultSchema:**真的在用**。workflow.js 构建自包含脚本时把它注入进去
|
|
6
|
+
// (kind 的 enum 按解析器注册表补齐),脚本里不再有第二份副本。
|
|
7
|
+
// - chunkReadSchema:**workflow 没用**。波次2 的子代理直接返回自由文本,
|
|
8
|
+
// 成稿时按 Markdown 拼接;这份留给程序化调用方(自建管线要结构化块输出时)。
|
|
9
|
+
// - qualityChecklistSchema:**workflow 没用**。波次3 的内嵌自检走脚本内的
|
|
10
|
+
// { pass, issues } 轻量 schema。
|
|
11
|
+
// 改这个文件会直接影响波次1 —— 改完跑 npm test(内含 schema 子集回归)。
|
|
6
12
|
//
|
|
7
13
|
// 注意:本 schema 子集遵循 DSH workflow agent() 的约束
|
|
8
14
|
// (type/properties/required/additionalProperties/items/enum/const/oneOf)。
|
|
15
|
+
// 违反子集 = 引擎抛 UNSUPPORTED_SCHEMA = 整条 workflow 终止(不是降级)。
|
|
9
16
|
// ============================================================================
|
|
10
17
|
|
|
11
18
|
/** 波次1:获取+分块 的结构化输出 */
|