dsh-zju-lecture-note 2.2.7 → 2.2.8
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 +85 -2
- package/README.md +47 -22
- package/SECURITY.md +72 -34
- package/docs/technical.md +66 -28
- package/lib/bridge.js +12 -2
- package/lib/client.js +142 -36
- package/lib/index.js +118 -15
- package/lib/tools.js +2 -2
- package/lib/tools.schema.json +2 -2
- package/mcp.json +21 -0
- package/mcp_server.py +85 -21
- package/package.json +5 -2
- package/plugin.json +19 -0
- package/server.mjs +118 -0
- package/skills/scholia-notes.manifest.json +1 -1
- package/skills/zju-lecture-summarizer/SKILL.md +13 -3
- package/skills/zju-lecture-summarizer/SLIDES.md +38 -3
- package/skills/zju-lecture-summarizer-help/SKILL.md +1 -1
- package/skills/zju-lecture-summarizer-help.manifest.json +4 -4
- package/skills/zju-lecture-summarizer-login.manifest.json +1 -1
- package/skills/zju-lecture-summarizer.manifest.json +6 -6
- package/zju_lecture/browser_login.py +174 -221
- package/zju_lecture/cli.py +24 -2
- package/zju_lecture/cookies.py +43 -4
- package/zju_lecture/credential_store.py +621 -0
- package/zju_lecture/deps.py +16 -0
- package/zju_lecture/handout.py +29 -3
- package/zju_lecture/study_notes.py +4 -0
package/lib/index.js
CHANGED
|
@@ -189,14 +189,25 @@ const Config = Schema.object({
|
|
|
189
189
|
enableSlides: Schema.boolean()
|
|
190
190
|
.description(
|
|
191
191
|
"启用「PPT 投影抓取」可选模块(默认关闭):开启后注册 zju_fetch_slides,"
|
|
192
|
-
+ "
|
|
192
|
+
+ "写讲义前会抓取投影截图清单;是否下载图片、是否把投影当作内容来源,"
|
|
193
|
+
+ "分别由 slidesAsSource / embedSlideImages 决定。关闭时不注册投影工具、不下载截图;"
|
|
193
194
|
+ "字幕鉴权由核心链路自动完成,与投影独立。",
|
|
194
195
|
)
|
|
195
196
|
.default(false)
|
|
196
197
|
.volatile(),
|
|
198
|
+
slidesAsSource: Schema.boolean()
|
|
199
|
+
.description(
|
|
200
|
+
"把课堂投影截图作为讲义内容来源(默认关闭;需先开启「PPT 投影抓取」):"
|
|
201
|
+
+ "开启后写讲义前会抓取并下载一次投影截图,把幻灯片上的定义、公式、图例与例题"
|
|
202
|
+
+ "同字幕对照写入讲义;模型看不到本地图片时不得臆造幻灯片文字,只在文末列出截图索引。"
|
|
203
|
+
+ "只需要插图、不需要以投影为内容来源时保持关闭。",
|
|
204
|
+
)
|
|
205
|
+
.default(false)
|
|
206
|
+
.volatile(),
|
|
197
207
|
embedSlideImages: Schema.boolean()
|
|
198
208
|
.description(
|
|
199
|
-
"把投影截图引用进讲义(需先开启「PPT 投影抓取」;默认关闭,节省下载时间与视觉 token
|
|
209
|
+
"把投影截图引用进讲义(需先开启「PPT 投影抓取」;默认关闭,节省下载时间与视觉 token):"
|
|
210
|
+
+ "只控制是否插入 3–8 张关键页,不改变「投影是否作为内容来源」。",
|
|
200
211
|
)
|
|
201
212
|
.default(false)
|
|
202
213
|
.volatile(),
|
|
@@ -278,6 +289,7 @@ function featureFlags(config = {}) {
|
|
|
278
289
|
renderPdf: value("renderPdf") !== false,
|
|
279
290
|
enableStudyNotes: value("enableStudyNotes") === true,
|
|
280
291
|
enableSlides,
|
|
292
|
+
slidesAsSource: enableSlides && value("slidesAsSource") === true,
|
|
281
293
|
embedSlideImages: enableSlides && value("embedSlideImages") === true,
|
|
282
294
|
enableLoginTools: value("enableLoginTools") === true,
|
|
283
295
|
typstAutoInstall: value("typstAutoInstall") !== false,
|
|
@@ -303,6 +315,7 @@ function bridgeOptions(config = {}) {
|
|
|
303
315
|
python: String(readSetting(config, "python") ?? ""),
|
|
304
316
|
timeoutMs: Number.isFinite(timeout) && timeout > 0 ? timeout : 120000,
|
|
305
317
|
enableSlides: flags.enableSlides,
|
|
318
|
+
slidesAsSource: flags.slidesAsSource,
|
|
306
319
|
embedSlideImages: flags.embedSlideImages,
|
|
307
320
|
enableStudyNotes: flags.enableStudyNotes,
|
|
308
321
|
enableLoginTools: flags.enableLoginTools,
|
|
@@ -353,7 +366,7 @@ function toolTimeoutFor(toolName, timeoutMs) {
|
|
|
353
366
|
|
|
354
367
|
const SYSTEM_PROMPT = [
|
|
355
368
|
"适用范围:仅处理浙大智云课堂(classroom.zju.edu.cn)回放与讲义任务;其他任务请忽略本段。",
|
|
356
|
-
"主链路:把链接或 sub_id 直接交给 zju_fetch_transcript(默认 per_minute;长课 chunked;同一节课只抓一次,per_segment 仅在确实需要秒级时间戳时用)→
|
|
369
|
+
"主链路:把链接或 sub_id 直接交给 zju_fetch_transcript(默认 per_minute;长课 chunked;同一节课只抓一次,per_segment 仅在确实需要秒级时间戳时用)→ 按下面的材料规则补齐投影或课件 → zju_write_note 一次写入。write_note 会自动命名、拒绝静默覆盖、修公式、校验,并按设置自动排版同名 PDF;不要再调 zju_parse_url,也不要对同一份讲义重复调 zju_check_note。",
|
|
357
370
|
"讲义默认按「复习版」写:每节保留 [HH:MM];老师讲过的例题整理成「题目 → 切入点 → 关键步骤 → 易错点」,本节没有例题就写「本节无例题」,不要编题;文末给 3–5 道自测题(答案用多行 <details> 折叠)与 5–10 条考点预测。",
|
|
358
371
|
"例题/定理/定义/证明要写成行首标记([例] 标题 —— 正文 / [定理] … / [定义] … / [证明] …),"
|
|
359
372
|
+ "不要写成 `#### 例 1:…` 或 `**证明**`——那种写法在 PDF 里只是小标题和粗体,排不出方框(工具会报 pseudo_box 警告)。",
|
|
@@ -366,18 +379,20 @@ const SYSTEM_PROMPT = [
|
|
|
366
379
|
/**
|
|
367
380
|
* The note-writing instruction for projected-slide images.
|
|
368
381
|
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
382
|
+
* `embedSlideImages` only decides whether screenshots go into the Markdown;
|
|
383
|
+
* whether the projection is a *content source* is `slidesAsSource`. Keeping
|
|
384
|
+
* the two apart matters because "read the slides" and "paste the slides" have
|
|
385
|
+
* different failure modes: a host without vision can still use the list as an
|
|
386
|
+
* index, but it must not pretend to have read an image.
|
|
371
387
|
*/
|
|
372
388
|
function slideImageRule(enabled) {
|
|
373
389
|
return enabled
|
|
374
|
-
? "
|
|
375
|
-
+ "从返回的截图里挑 3–8 张关键页(定义、示意图、公式推导、例题),"
|
|
390
|
+
? "讲义插图模式已开启:从下载结果里挑 3–8 张关键页(定义、示意图、公式推导、例题),"
|
|
376
391
|
+ "按讲义所在目录的相对路径插入 Markdown(例如 );"
|
|
377
392
|
+ "如果宿主不能查看本地图片,不要把截图当作已读文字,只在文末列出截图索引。"
|
|
378
|
-
+ "
|
|
379
|
-
: "
|
|
380
|
-
+ "用户明确要求看图时再调用 zju_fetch_slides(download=true),并在文末列截图索引。";
|
|
393
|
+
+ "不要一次塞入全部截图或图片字节。"
|
|
394
|
+
: "讲义插图模式关闭(节省下载时间与 token):不要插入截图;"
|
|
395
|
+
+ "用户明确要求看图时再调用 zju_fetch_slides(download=true, confirm=true),并在文末列截图索引。";
|
|
381
396
|
}
|
|
382
397
|
|
|
383
398
|
/**
|
|
@@ -387,15 +402,65 @@ function slideImageRule(enabled) {
|
|
|
387
402
|
* registered, so the prompt must not lead the model into calling them (or
|
|
388
403
|
* reading browser cookies "just in case"). The transcript path never depends
|
|
389
404
|
* on any of this.
|
|
405
|
+
*
|
|
406
|
+
* When the module is on, the prompt always names the projected-slide step in
|
|
407
|
+
* the material order. The previous wording only asked for a call when
|
|
408
|
+
* `embedSlideImages` was on, so a user who enabled "抓取投影截图" alone saw the
|
|
409
|
+
* agent skip the tool entirely. That is a configuration inconsistency, not a
|
|
410
|
+
* model preference: the switch promised capture and the prompt forbade it.
|
|
390
411
|
*/
|
|
391
|
-
function slidesFeatureRule(enableSlides, embedSlideImages) {
|
|
412
|
+
function slidesFeatureRule(enableSlides, embedSlideImages, slidesAsSource = false) {
|
|
392
413
|
if (!enableSlides) {
|
|
393
414
|
return "PPT 投影抓取已关闭(插件设置 enableSlides=false):本会话没有注册 zju_fetch_slides,"
|
|
394
415
|
+ "不要尝试抓取或引用投影截图,也不要为了投影额外读取浏览器 Cookie;"
|
|
395
416
|
+ "字幕鉴权由字幕工具自行处理,需要登录时用 zju_login。只用语音字幕与本地课件生成讲义。"
|
|
396
417
|
+ "用户明确要投影画面时,告诉他在插件设置里打开「启用 PPT 投影抓取」后重试。";
|
|
397
418
|
}
|
|
398
|
-
|
|
419
|
+
if (slidesAsSource) {
|
|
420
|
+
return "PPT 投影抓取已开启(enableSlides=true),投影作为讲义来源已开启(slidesAsSource=true):"
|
|
421
|
+
+ "写讲义前必须先调用一次 zju_fetch_slides(url_or_sub_id=<回放链接>, download=true, confirm=true),"
|
|
422
|
+
+ "整节课只抓一次,不要因为一次失败就反复重试或更换后端。"
|
|
423
|
+
+ "把投影当作与字幕并列的内容来源:定义、公式、图例、例题按幻灯片与字幕互相校正,写进对应小节。"
|
|
424
|
+
+ "如果当前宿主能读取本地图片,逐页查看关键截图后再写;不能读图时不要臆造幻灯片文字,"
|
|
425
|
+
+ "只在文末列「课堂投影截图索引」并说明哪些内容未核对。"
|
|
426
|
+
+ "登录失败时按工具返回调用 zju_login 后重试一次;仍失败就降级为纯字幕,并在讲义开头注明投影未使用。"
|
|
427
|
+
+ (embedSlideImages
|
|
428
|
+
? "讲义插图模式已开启:再挑 3–8 张关键页按相对路径插入。"
|
|
429
|
+
: "本次不插入截图(embedSlideImages=false),但投影内容仍必须用于正文。");
|
|
430
|
+
}
|
|
431
|
+
if (embedSlideImages) {
|
|
432
|
+
return "PPT 投影抓取已开启(enableSlides=true,讲义插图模式已开启):"
|
|
433
|
+
+ "写讲义前先调用一次 zju_fetch_slides(download=true, confirm=true)(整节课只抓一次),"
|
|
434
|
+
+ "从返回的截图里挑 3–8 张关键页插入对应小节;"
|
|
435
|
+
+ "如果宿主不能查看本地图片,只把截图当作索引,不要臆造幻灯片文字。"
|
|
436
|
+
+ "用户明确说不要投影时才跳过。";
|
|
437
|
+
}
|
|
438
|
+
return "PPT 投影抓取已开启(enableSlides=true,slidesAsSource=false、embedSlideImages=false):"
|
|
439
|
+
+ "写讲义前调用一次 zju_fetch_slides(download=false) 核对投影清单(整节课只抓一次);"
|
|
440
|
+
+ "不要下载截图、不要插入图片,也不要把截图当作内容来源。"
|
|
441
|
+
+ "如果只是登录态不可用,跳过投影并用字幕照常生成讲义,不要为了投影打断用户。"
|
|
442
|
+
+ "用户明确要看投影时再传 download=true, confirm=true 并列出截图索引。";
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* The material order for this session, stated once and before the generic
|
|
447
|
+
* pipeline. It is what makes "投影讲义" presets behave like a real pipeline
|
|
448
|
+
* step instead of an optional appendix the model may or may not read.
|
|
449
|
+
*/
|
|
450
|
+
function materialRule(flags) {
|
|
451
|
+
if (!flags.enableSlides) return "";
|
|
452
|
+
if (flags.slidesAsSource) {
|
|
453
|
+
return "材料顺序(投影讲义模式):zju_fetch_transcript 抓字幕 → "
|
|
454
|
+
+ "zju_fetch_slides(download=true, confirm=true) 抓一次投影 →"
|
|
455
|
+
+ "(可选 zju_extract_courseware)→ zju_write_note。投影是必做材料,不是可选项;整节课只抓一次。";
|
|
456
|
+
}
|
|
457
|
+
if (flags.embedSlideImages) {
|
|
458
|
+
return "材料顺序:zju_fetch_transcript 抓字幕 → "
|
|
459
|
+
+ "zju_fetch_slides(download=true, confirm=true) 抓一次投影 →"
|
|
460
|
+
+ "(可选 zju_extract_courseware)→ zju_write_note。投影截图用于插图,整节课只抓一次。";
|
|
461
|
+
}
|
|
462
|
+
return "材料顺序:zju_fetch_transcript 抓字幕 → zju_fetch_slides(download=false) 核对一次投影清单 →"
|
|
463
|
+
+ "(可选 zju_extract_courseware)→ zju_write_note。投影清单不下载、不插图。";
|
|
399
464
|
}
|
|
400
465
|
|
|
401
466
|
function pdfFeatureRule(enabled) {
|
|
@@ -456,7 +521,8 @@ function skillFeatureRule(enabled) {
|
|
|
456
521
|
function buildSystemPrompt(flags) {
|
|
457
522
|
return [
|
|
458
523
|
SYSTEM_PROMPT,
|
|
459
|
-
|
|
524
|
+
materialRule(flags),
|
|
525
|
+
slidesFeatureRule(flags.enableSlides, flags.embedSlideImages, flags.slidesAsSource),
|
|
460
526
|
pdfFeatureRule(flags.renderPdf),
|
|
461
527
|
studyFeatureRule(flags.enableStudyNotes, flags.registerSkill),
|
|
462
528
|
formulaFeatureRule(flags.registerSkill),
|
|
@@ -531,13 +597,41 @@ function splitFrontmatter(raw) {
|
|
|
531
597
|
return { description, body };
|
|
532
598
|
}
|
|
533
599
|
|
|
600
|
+
/**
|
|
601
|
+
* The mode-specific paragraph appended to the transcript Skill.
|
|
602
|
+
*
|
|
603
|
+
* `SLIDES.md` documents every projection mode, but the model reads a Skill
|
|
604
|
+
* selectively. Stating this session's mode at the end keeps "仅注册 / 插图 /
|
|
605
|
+
* 讲义素材" from being confused with one another, and it is regenerated when
|
|
606
|
+
* the settings change (`syncSkills` includes `slidesAsSource` in its signature).
|
|
607
|
+
*/
|
|
608
|
+
function slidesModeAppendix(flags) {
|
|
609
|
+
if (!flags.enableSlides) return "";
|
|
610
|
+
if (flags.slidesAsSource) {
|
|
611
|
+
return "## 本次会话:投影作为讲义来源\n"
|
|
612
|
+
+ "系统提示已开启 slidesAsSource。写讲义前必须先调用一次 "
|
|
613
|
+
+ "zju_fetch_slides(download=true, confirm=true),整节课只抓一次;"
|
|
614
|
+
+ "把幻灯片上的定义、公式、图例、例题与字幕对照写进正文。"
|
|
615
|
+
+ "宿主不能读图时不要臆造幻灯片文字,只在文末列截图索引并说明哪些内容未核对。"
|
|
616
|
+
+ "登录失败按提示调用 zju_login 后重试一次,仍失败则降级为纯字幕并在讲义开头注明。";
|
|
617
|
+
}
|
|
618
|
+
if (flags.embedSlideImages) {
|
|
619
|
+
return "## 本次会话:投影插图\n"
|
|
620
|
+
+ "系统提示已开启 embedSlideImages。写讲义前抓一次投影(download=true, confirm=true),"
|
|
621
|
+
+ "挑 3–8 张关键页插入对应小节;宿主不能读图时不要臆造幻灯片文字,只在文末列索引。";
|
|
622
|
+
}
|
|
623
|
+
return "## 本次会话:投影清单\n"
|
|
624
|
+
+ "系统提示已开启 enableSlides。写讲义前调用一次 zju_fetch_slides(download=false) 核对清单;"
|
|
625
|
+
+ "不下载、不插图、不把截图当内容来源;登录态不可用时直接跳过投影,用字幕照常生成讲义。";
|
|
626
|
+
}
|
|
627
|
+
|
|
534
628
|
/**
|
|
535
629
|
* Read the bundled skills for in-memory registration.
|
|
536
630
|
*
|
|
537
631
|
* The plugin is installed under a pnpm store path, so the skill files ship
|
|
538
632
|
* inside the package and are read from there; nothing is copied into the user's
|
|
539
633
|
* home directory. The projection appendix is concatenated only when the
|
|
540
|
-
* optional module is enabled.
|
|
634
|
+
* optional module is enabled, followed by this session's projection mode.
|
|
541
635
|
*
|
|
542
636
|
* @param {object|boolean} configOrSlides plugin config (or a bare slides flag)
|
|
543
637
|
* @returns {Array<object>} skill descriptors ready for the registry
|
|
@@ -558,6 +652,7 @@ function readBundledSkills(configOrSlides = {}) {
|
|
|
558
652
|
const raw = readFileSync(file, "utf8");
|
|
559
653
|
const { description, body } = splitFrontmatter(raw);
|
|
560
654
|
let content = body;
|
|
655
|
+
const carriesSlides = spec.appendices.some((appendix) => appendix.when === "slides");
|
|
561
656
|
for (const appendix of spec.appendices) {
|
|
562
657
|
if (appendix.when === "slides" && !flags.enableSlides) continue;
|
|
563
658
|
const appendixFile = appendix.path;
|
|
@@ -568,6 +663,10 @@ function readBundledSkills(configOrSlides = {}) {
|
|
|
568
663
|
const text = splitFrontmatter(readFileSync(appendixFile, "utf8")).body.trim();
|
|
569
664
|
if (text) content = `${body.trimEnd()}\n\n---\n\n${text}\n`;
|
|
570
665
|
}
|
|
666
|
+
if (carriesSlides && flags.enableSlides) {
|
|
667
|
+
const modeNote = slidesModeAppendix(flags);
|
|
668
|
+
if (modeNote) content = `${content.trimEnd()}\n\n---\n\n${modeNote}\n`;
|
|
669
|
+
}
|
|
571
670
|
const descriptor = {
|
|
572
671
|
name: spec.name,
|
|
573
672
|
description: description || spec.fallbackDescription,
|
|
@@ -713,13 +812,15 @@ function apply(ctx, config = {}) {
|
|
|
713
812
|
}
|
|
714
813
|
};
|
|
715
814
|
|
|
716
|
-
/** Reconcile the in-memory Skill set with
|
|
815
|
+
/** Reconcile the in-memory Skill set with the projection / study switches. */
|
|
717
816
|
const syncSkills = () => {
|
|
718
817
|
if (!skillsScope) return;
|
|
719
818
|
const flags = featureFlags(config);
|
|
720
819
|
const signature = JSON.stringify({
|
|
721
820
|
registerSkill: flags.registerSkill,
|
|
722
821
|
enableSlides: flags.enableSlides,
|
|
822
|
+
slidesAsSource: flags.slidesAsSource,
|
|
823
|
+
embedSlideImages: flags.embedSlideImages,
|
|
723
824
|
enableStudyNotes: flags.enableStudyNotes,
|
|
724
825
|
});
|
|
725
826
|
if (signature === skillSignature) return;
|
|
@@ -802,11 +903,13 @@ export {
|
|
|
802
903
|
bridgeOptions,
|
|
803
904
|
buildSystemPrompt,
|
|
804
905
|
featureFlags,
|
|
906
|
+
materialRule,
|
|
805
907
|
name,
|
|
806
908
|
readBundledSkills,
|
|
807
909
|
readSetting,
|
|
808
910
|
registerableTools,
|
|
809
911
|
slideImageRule,
|
|
810
912
|
slidesFeatureRule,
|
|
913
|
+
slidesModeAppendix,
|
|
811
914
|
splitFrontmatter,
|
|
812
915
|
};
|
package/lib/tools.js
CHANGED
|
@@ -60,7 +60,7 @@ export const ZJU_TOOLS = [
|
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
"name": "zju_fetch_slides",
|
|
63
|
-
"description": "
|
|
63
|
+
"description": "(投影模块)抓取智云课堂投影 PPT 截图清单。search-ppt 返回的是投影截图,不是文字层/OCR;download=true 时下载截图并合成 PDF。当插件把投影作为讲义来源(slidesAsSource / ZJU_SLIDES_SOURCE=1)时,写讲义前应调用一次并传 download=true, confirm=true;download 省略时跟随 slidesAsSource / embedSlideImages(ZJU_SLIDES_SOURCE / ZJU_EMBED_SLIDES)。需要登录态(Cookie 含 _token,由服务端本地解析,不接受也不回显 Cookie)。抓不到时返回诊断,可降级为纯字幕总结。dsh 的 enableSlides(ZJU_ENABLE_SLIDES)关闭时本工具不注册。",
|
|
64
64
|
"parameters": {
|
|
65
65
|
"url_or_sub_id": {
|
|
66
66
|
"description": "回放 URL(通常含 course_id)或 sub_id",
|
|
@@ -77,7 +77,7 @@ export const ZJU_TOOLS = [
|
|
|
77
77
|
"type": "string"
|
|
78
78
|
},
|
|
79
79
|
"download": {
|
|
80
|
-
"description": "是否下载截图到工作区并合成 PDF。省略时跟随插件设置(
|
|
80
|
+
"description": "是否下载截图到工作区并合成 PDF。省略时跟随插件设置(slidesAsSource 或 embedSlideImages 开启即下载;环境变量 ZJU_SLIDES_SOURCE / ZJU_EMBED_SLIDES);显式传 true/false 可覆盖。一节 1 小时的课通常有几十到几百张截图",
|
|
81
81
|
"type": "boolean"
|
|
82
82
|
},
|
|
83
83
|
"output_dir": {
|
package/lib/tools.schema.json
CHANGED
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
"name": "zju_fetch_slides",
|
|
55
|
-
"description": "
|
|
55
|
+
"description": "(投影模块)抓取智云课堂投影 PPT 截图清单。search-ppt 返回的是投影截图,不是文字层/OCR;download=true 时下载截图并合成 PDF。当插件把投影作为讲义来源(slidesAsSource / ZJU_SLIDES_SOURCE=1)时,写讲义前应调用一次并传 download=true, confirm=true;download 省略时跟随 slidesAsSource / embedSlideImages(ZJU_SLIDES_SOURCE / ZJU_EMBED_SLIDES)。需要登录态(Cookie 含 _token,由服务端本地解析,不接受也不回显 Cookie)。抓不到时返回诊断,可降级为纯字幕总结。dsh 的 enableSlides(ZJU_ENABLE_SLIDES)关闭时本工具不注册。",
|
|
56
56
|
"parameters": {
|
|
57
57
|
"url_or_sub_id": {
|
|
58
58
|
"description": "回放 URL(通常含 course_id)或 sub_id",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"type": "string"
|
|
70
70
|
},
|
|
71
71
|
"download": {
|
|
72
|
-
"description": "是否下载截图到工作区并合成 PDF。省略时跟随插件设置(
|
|
72
|
+
"description": "是否下载截图到工作区并合成 PDF。省略时跟随插件设置(slidesAsSource 或 embedSlideImages 开启即下载;环境变量 ZJU_SLIDES_SOURCE / ZJU_EMBED_SLIDES);显式传 true/false 可覆盖。一节 1 小时的课通常有几十到几百张截图",
|
|
73
73
|
"type": "boolean"
|
|
74
74
|
},
|
|
75
75
|
"output_dir": {
|
package/mcp.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json",
|
|
3
|
+
"mcpServers": {
|
|
4
|
+
"zju-lecture": {
|
|
5
|
+
"type": "stdio",
|
|
6
|
+
"command": "node",
|
|
7
|
+
"args": [
|
|
8
|
+
"./server.mjs"
|
|
9
|
+
],
|
|
10
|
+
"env": {
|
|
11
|
+
"ZJU_ENABLE_SLIDES": "0",
|
|
12
|
+
"ZJU_SLIDES_SOURCE": "0",
|
|
13
|
+
"ZJU_EMBED_SLIDES": "0",
|
|
14
|
+
"ZJU_ENABLE_STUDY_NOTES": "0",
|
|
15
|
+
"ZJU_ENABLE_LOGIN_TOOLS": "0",
|
|
16
|
+
"ZJU_RENDER_PDF": "0",
|
|
17
|
+
"ZJU_TYPST_AUTO_INSTALL": "1"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/mcp_server.py
CHANGED
|
@@ -98,7 +98,7 @@ from zju_lecture.study_notes import (
|
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
SERVER_NAME = "zju-lecture-mcp"
|
|
101
|
-
SERVER_VERSION = "2.2.
|
|
101
|
+
SERVER_VERSION = "2.2.8"
|
|
102
102
|
DEFAULT_TENANT = "112"
|
|
103
103
|
DEFAULT_DOMAIN = "classroom.zju.edu.cn"
|
|
104
104
|
|
|
@@ -111,6 +111,10 @@ COOKIE_ENV = "ZJU_COOKIE"
|
|
|
111
111
|
COOKIE_FILE_ENV = "ZJU_COOKIE_FILE"
|
|
112
112
|
_MAX_COOKIE_FILE_BYTES = 64 * 1024
|
|
113
113
|
|
|
114
|
+
#: Sub-switch of the projection pipeline: use the screenshots as a *content
|
|
115
|
+
#: source* (read the slides, then write the note from transcript + slides).
|
|
116
|
+
#: Distinct from EMBED_SLIDES_ENV, which only controls Markdown illustrations.
|
|
117
|
+
SLIDES_SOURCE_ENV = "ZJU_SLIDES_SOURCE"
|
|
114
118
|
#: Sub-switch of the projection pipeline: download projected-slide screenshots
|
|
115
119
|
#: and reference them in the note. Off by default because it adds download
|
|
116
120
|
#: time and vision tokens.
|
|
@@ -202,6 +206,16 @@ def available_tools() -> List[Dict[str, Any]]:
|
|
|
202
206
|
return [tool for tool in TOOLS if tool["name"] not in hidden]
|
|
203
207
|
|
|
204
208
|
|
|
209
|
+
def slides_as_source_enabled() -> bool:
|
|
210
|
+
"""Whether the host asked to use projected slides as a note source.
|
|
211
|
+
|
|
212
|
+
This is independent of the illustration sub-switch: a note can be written
|
|
213
|
+
from the slides without embedding any screenshot, and it can embed key
|
|
214
|
+
pages without treating the slide text as a source.
|
|
215
|
+
"""
|
|
216
|
+
return str(os.environ.get(SLIDES_SOURCE_ENV, "")).strip().lower() in _TRUE_VALUES
|
|
217
|
+
|
|
218
|
+
|
|
205
219
|
def embed_slides_enabled() -> bool:
|
|
206
220
|
"""Whether the host asked for projected-slide images in the note.
|
|
207
221
|
|
|
@@ -215,15 +229,21 @@ def slide_image_mode_text() -> str:
|
|
|
215
229
|
"""One sentence describing the note-illustration mode for this process."""
|
|
216
230
|
if not slides_enabled():
|
|
217
231
|
return "投影抓取已关闭,讲义只使用字幕与本地课件。"
|
|
232
|
+
if slides_as_source_enabled():
|
|
233
|
+
return (
|
|
234
|
+
"投影作为讲义来源:开启。写讲义前必须先抓一次投影(整节课只抓一次)并下载截图,"
|
|
235
|
+
"把幻灯片上的定义、公式、图例、例题与字幕对照写进正文;"
|
|
236
|
+
"模型不能查看本地图片时,只在文末列截图索引,不要臆造幻灯片文字。"
|
|
237
|
+
)
|
|
218
238
|
if embed_slides_enabled():
|
|
219
239
|
return (
|
|
220
|
-
"
|
|
240
|
+
"讲义插图模式:开启。写讲义前抓一次投影(整节课只抓一次),"
|
|
221
241
|
"从返回的截图里挑 3–8 张关键页,按讲义所在目录的相对路径插入 Markdown;"
|
|
222
242
|
"模型不能查看本地图片时,只在文末列截图索引,不要臆造截图内容。"
|
|
223
243
|
)
|
|
224
244
|
return (
|
|
225
|
-
"
|
|
226
|
-
"
|
|
245
|
+
"投影只启用抓取:写讲义前可调用一次 zju_fetch_slides(download=false) 核对清单,"
|
|
246
|
+
"不下载、不插图、不把截图当作内容来源。"
|
|
227
247
|
)
|
|
228
248
|
|
|
229
249
|
|
|
@@ -260,6 +280,12 @@ def server_instructions() -> str:
|
|
|
260
280
|
parts.append(
|
|
261
281
|
"投影截图(可下载并合成 PDF)需要登录态(Cookie 需含 _token);"
|
|
262
282
|
"投影抓取可用 ZJU_ENABLE_SLIDES=0 关闭。"
|
|
283
|
+
+ (
|
|
284
|
+
"投影作为讲义来源已开启(ZJU_SLIDES_SOURCE=1):写讲义前先抓取一次并下载截图,"
|
|
285
|
+
"结合字幕与幻灯片内容写;不能看图时不要臆造幻灯片文字。"
|
|
286
|
+
if slides_as_source_enabled()
|
|
287
|
+
else ""
|
|
288
|
+
)
|
|
263
289
|
)
|
|
264
290
|
else:
|
|
265
291
|
parts.append(
|
|
@@ -518,11 +544,14 @@ TOOLS: List[Dict[str, Any]] = [
|
|
|
518
544
|
{
|
|
519
545
|
"name": "zju_fetch_slides",
|
|
520
546
|
"description": (
|
|
521
|
-
"
|
|
522
|
-
"投影截图,不是文字层/OCR;download=true 时下载截图并合成 PDF
|
|
523
|
-
"
|
|
547
|
+
"(投影模块)抓取智云课堂投影 PPT 截图清单。search-ppt 返回的是"
|
|
548
|
+
"投影截图,不是文字层/OCR;download=true 时下载截图并合成 PDF。"
|
|
549
|
+
"当插件把投影作为讲义来源(slidesAsSource / ZJU_SLIDES_SOURCE=1)时,"
|
|
550
|
+
"写讲义前应调用一次并传 download=true, confirm=true;download 省略时"
|
|
551
|
+
"跟随 slidesAsSource / embedSlideImages(ZJU_SLIDES_SOURCE / ZJU_EMBED_SLIDES)。"
|
|
524
552
|
"需要登录态(Cookie 含 _token,由服务端本地解析,不接受也不回显 Cookie)。"
|
|
525
|
-
"抓不到时返回诊断,可降级为纯字幕总结。
|
|
553
|
+
"抓不到时返回诊断,可降级为纯字幕总结。"
|
|
554
|
+
"dsh 的 enableSlides(ZJU_ENABLE_SLIDES)关闭时本工具不注册。"
|
|
526
555
|
),
|
|
527
556
|
"inputSchema": {
|
|
528
557
|
"type": "object",
|
|
@@ -548,7 +577,8 @@ TOOLS: List[Dict[str, Any]] = [
|
|
|
548
577
|
"type": "boolean",
|
|
549
578
|
"description": (
|
|
550
579
|
"是否下载截图到工作区并合成 PDF。省略时跟随插件设置"
|
|
551
|
-
"(
|
|
580
|
+
"(slidesAsSource 或 embedSlideImages 开启即下载;"
|
|
581
|
+
"环境变量 ZJU_SLIDES_SOURCE / ZJU_EMBED_SLIDES);"
|
|
552
582
|
"显式传 true/false 可覆盖。一节 1 小时的课通常有几十到几百张截图"
|
|
553
583
|
),
|
|
554
584
|
},
|
|
@@ -1097,7 +1127,7 @@ _LOGIN_SOURCE_LABELS = {
|
|
|
1097
1127
|
"cache": "进程内缓存",
|
|
1098
1128
|
"env": "ZJU_COOKIE",
|
|
1099
1129
|
"file": "ZJU_COOKIE_FILE",
|
|
1100
|
-
"session": "zju_login
|
|
1130
|
+
"session": "zju_login 保存(加密)",
|
|
1101
1131
|
"edge": "本机 Edge",
|
|
1102
1132
|
}
|
|
1103
1133
|
|
|
@@ -1120,7 +1150,8 @@ def _login_status_text() -> List[str]:
|
|
|
1120
1150
|
lines.append(
|
|
1121
1151
|
" 本机保存的登录态: 存在"
|
|
1122
1152
|
f"({summary.get('cookie_count', 0)} 条 Cookie,"
|
|
1123
|
-
f"浏览器 {summary.get('browser') or '未知'}
|
|
1153
|
+
f"浏览器 {summary.get('browser') or '未知'},"
|
|
1154
|
+
f"存储 {summary.get('storage') or '未知'})"
|
|
1124
1155
|
)
|
|
1125
1156
|
return lines
|
|
1126
1157
|
action = COOKIE_FAILURE_ACTIONS.get(reason or "unknown", COOKIE_FAILURE_ACTIONS["unknown"])
|
|
@@ -1186,8 +1217,13 @@ def _doctor_report(install: bool, check_login: bool = False) -> str:
|
|
|
1186
1217
|
+ (f",保存于 {stamp}" if stamp else "")
|
|
1187
1218
|
+ ";不含账号密码)"
|
|
1188
1219
|
)
|
|
1220
|
+
lines.append(f" 存储: {summary.get('storage') or '未知'}")
|
|
1189
1221
|
else:
|
|
1190
1222
|
lines.append("本机登录态: 未保存(需要时调用 zju_login 打开独立登录窗口)")
|
|
1223
|
+
if summary.get("backend"):
|
|
1224
|
+
lines.append(
|
|
1225
|
+
f" 存储: {summary.get('storage') or summary.get('backend')}"
|
|
1226
|
+
)
|
|
1191
1227
|
login_ok, login_detail = login_available()
|
|
1192
1228
|
lines.append(
|
|
1193
1229
|
"登录窗口: " + ("可用(" + login_detail + ")" if login_ok else "不可用(" + login_detail + ")")
|
|
@@ -1539,6 +1575,12 @@ def _dispatch_tool(name: str, arguments: Dict[str, Any]) -> Any:
|
|
|
1539
1575
|
f"{REDACTOR.redact(result['profile_error'])}。"
|
|
1540
1576
|
"请先关闭该登录窗口,再重试清除。"
|
|
1541
1577
|
)
|
|
1578
|
+
if result.get("backend_error"):
|
|
1579
|
+
lines.append(
|
|
1580
|
+
"凭据库中的登录态未能清除:"
|
|
1581
|
+
f"{REDACTOR.redact(str(result['backend_error']))}。"
|
|
1582
|
+
"可在系统钥匙串/密钥环里手动删除后重试。"
|
|
1583
|
+
)
|
|
1542
1584
|
return "\n".join(lines)
|
|
1543
1585
|
|
|
1544
1586
|
timeout = arguments.get("timeout_seconds") or 300
|
|
@@ -1559,14 +1601,24 @@ def _dispatch_tool(name: str, arguments: Dict[str, Any]) -> Any:
|
|
|
1559
1601
|
]
|
|
1560
1602
|
if result.get("saved"):
|
|
1561
1603
|
lines.append(
|
|
1562
|
-
|
|
1563
|
-
"
|
|
1604
|
+
"- 保存: 已加密保存到 "
|
|
1605
|
+
f"{result.get('storage') or '系统凭据库'}(不含账号密码)"
|
|
1564
1606
|
)
|
|
1565
1607
|
else:
|
|
1566
1608
|
lines.append(
|
|
1567
1609
|
"- 保存: 未落盘("
|
|
1568
|
-
f"{
|
|
1569
|
-
|
|
1610
|
+
f"{result.get('storage') or '本机没有可用的加密凭据库'})"
|
|
1611
|
+
)
|
|
1612
|
+
advice = str(result.get("storage_advice") or "").strip()
|
|
1613
|
+
if advice:
|
|
1614
|
+
lines.append(f"- 说明: {REDACTOR.redact(advice)}")
|
|
1615
|
+
if result.get("save_error"):
|
|
1616
|
+
lines.append(f"- 保存失败原因: {REDACTOR.redact(result['save_error'])}")
|
|
1617
|
+
if result.get("profile_error"):
|
|
1618
|
+
lines.append(
|
|
1619
|
+
"- 独立登录窗口配置未能清理:"
|
|
1620
|
+
f"{REDACTOR.redact(str(result['profile_error']))};"
|
|
1621
|
+
"可运行 zju_login(clear=true) 重试。"
|
|
1570
1622
|
)
|
|
1571
1623
|
lines.append("现在可以重试字幕或投影抓取,不需要再操作浏览器。")
|
|
1572
1624
|
return "\n".join(lines)
|
|
@@ -1671,7 +1723,10 @@ def _dispatch_tool(name: str, arguments: Dict[str, Any]) -> Any:
|
|
|
1671
1723
|
course_id = str(arguments.get("course_id") or parsed.get("course_id") or "")
|
|
1672
1724
|
download_arg = arguments.get("download")
|
|
1673
1725
|
slide_images_enabled = embed_slides_enabled()
|
|
1674
|
-
|
|
1726
|
+
slides_as_source = slides_as_source_enabled()
|
|
1727
|
+
download = (
|
|
1728
|
+
slide_images_enabled or slides_as_source
|
|
1729
|
+
) if download_arg is None else bool(download_arg)
|
|
1675
1730
|
dedup_arg = arguments.get("dedup")
|
|
1676
1731
|
dedup = True if dedup_arg is None else bool(dedup_arg)
|
|
1677
1732
|
output_dir = str(arguments.get("output_dir") or "").strip()
|
|
@@ -1757,18 +1812,27 @@ def _dispatch_tool(name: str, arguments: Dict[str, Any]) -> Any:
|
|
|
1757
1812
|
download_note += f"\nPDF: {pdf_path}({len(pages)} 页)"
|
|
1758
1813
|
|
|
1759
1814
|
md = format_slides_as_markdown(slides_data, pdf_path=pdf_path)
|
|
1760
|
-
mode_text = "开启" if slide_images_enabled else
|
|
1815
|
+
mode_text = "开启" if slide_images_enabled else (
|
|
1816
|
+
"关闭" if slides_as_source else "关闭(默认)"
|
|
1817
|
+
)
|
|
1818
|
+
source_text = "开启" if slides_as_source else "关闭(默认)"
|
|
1761
1819
|
lines = [
|
|
1762
1820
|
f"=== 课堂投影 PPT 截图 (sub_id={sub_id}, 共 {len(slides_data)} 页) ===",
|
|
1821
|
+
f"投影作为讲义来源: {source_text}"
|
|
1822
|
+
"(dsh 设置 slidesAsSource / 环境变量 ZJU_SLIDES_SOURCE)",
|
|
1763
1823
|
f"讲义插图模式: {mode_text}"
|
|
1764
1824
|
"(dsh 设置 embedSlideImages / 环境变量 ZJU_EMBED_SLIDES)",
|
|
1765
1825
|
"说明: 智云接口返回的是投影画面截图,不是文字层;"
|
|
1766
|
-
"
|
|
1826
|
+
"未下载或模型不能看图时,不要臆造幻灯片文字,只用字幕与本地课件生成讲义。",
|
|
1767
1827
|
]
|
|
1768
|
-
if
|
|
1828
|
+
if slides_as_source and download:
|
|
1829
|
+
lines.append(
|
|
1830
|
+
"投影讲义模式:请结合截图内容与字幕写讲义;不能读图时只在文末列截图索引并说明。"
|
|
1831
|
+
)
|
|
1832
|
+
if download and not slide_images_enabled and not slides_as_source:
|
|
1769
1833
|
lines.append("本次按显式 download=true 执行。")
|
|
1770
|
-
elif slide_images_enabled and not download:
|
|
1771
|
-
lines.append("本次 download=false
|
|
1834
|
+
elif (slide_images_enabled or slides_as_source) and not download:
|
|
1835
|
+
lines.append("本次 download=false,未下载截图;投影模式通常应下载后阅读。")
|
|
1772
1836
|
if download_note:
|
|
1773
1837
|
lines.append(download_note)
|
|
1774
1838
|
if note_example:
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-zju-lecture-note",
|
|
3
|
-
"version": "2.2.
|
|
4
|
-
"description": "浙大智云课堂回放讲义插件(DeepSeek Harness 原生插件):以「语音字幕 + 本地课件」为主链路,写完讲义自动排版同名 PDF;可选启用投影 PPT 截图抓取、基于 Typst scholia
|
|
3
|
+
"version": "2.2.8",
|
|
4
|
+
"description": "浙大智云课堂回放讲义插件(DeepSeek Harness 原生插件):以「语音字幕 + 本地课件」为主链路,写完讲义自动排版同名 PDF;可选启用投影 PPT 截图抓取、基于 Typst scholia 模板排版的填空式学习笔记与登录辅助工具;一键登录窗口让用户正常登录后把登录态加密保存到平台凭据库(Windows DPAPI / macOS 钥匙串 / Linux 密钥环,无可用凭据库时不落盘),不回显、不进入对话、不保存密码",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "chenqianyu486",
|
|
7
7
|
"icon": "icon.png",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"files": [
|
|
38
38
|
"cordis.patch.yml",
|
|
39
39
|
"lib",
|
|
40
|
+
"plugin.json",
|
|
41
|
+
"mcp.json",
|
|
42
|
+
"server.mjs",
|
|
40
43
|
"mcp_server.py",
|
|
41
44
|
"zju_lecture/*.py",
|
|
42
45
|
"zju_lecture/cacert.pem",
|
package/plugin.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
|
+
"name": "zju-lecture",
|
|
4
|
+
"version": "2.2.8",
|
|
5
|
+
"description": "浙大智云课堂回放讲义:语音字幕 + 本地课件 → 结构化讲义与 PDF(MCP + Agent Skills)",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "chenqianyu486"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/chenqianyu486-sys/dsh-zju-lecture-note#readme",
|
|
10
|
+
"repository": "https://github.com/chenqianyu486-sys/dsh-zju-lecture-note",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"zju",
|
|
14
|
+
"lecture",
|
|
15
|
+
"mcp",
|
|
16
|
+
"agent-skill",
|
|
17
|
+
"typst"
|
|
18
|
+
]
|
|
19
|
+
}
|