@thanh01.pmt/presentation-kit 0.2.11 → 0.2.13

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/dist/ai/index.js CHANGED
@@ -410,7 +410,326 @@ When a precise coordinate layout is specified, include the clean YAML block at t
410
410
  pos: [670, 150, 530, 510]
411
411
  -->
412
412
  \`\`\`
413
+
414
+ ---
415
+
416
+ ## 7. STEP REVEAL & PROGRESSIVE DISCLOSURE
417
+ When presenting lists, comparisons, or multi-phase concepts, support sequential reveals:
418
+ - Annotate lists or elements with \`<!-- v-click -->\` or apply class \`.step-reveal\` / \`[data-step]\`.
419
+ - Clicking or pressing forward arrow reveals items sequentially before transitioning to the next slide.
420
+ - Keep list items concise (< 15 words) to maintain visual rhythm during progressive steps.
413
421
  `;
422
+ var validateSlideDeckSchema = z.object({
423
+ format: z.enum(["auto", "html", "markdown"]).default("auto").describe('Deck format to validate: "html", "markdown", or "auto"'),
424
+ markdown: z.string().optional().describe("Raw Markdown / Marp slide presentation content"),
425
+ htmlDeck: z.object({
426
+ title: z.string().optional(),
427
+ subtitle: z.string().optional(),
428
+ theme: z.string().optional(),
429
+ slides: z.array(z.object({
430
+ layoutId: z.string(),
431
+ slots: z.record(z.any()),
432
+ notes: z.string().optional()
433
+ })).optional()
434
+ }).optional().describe("Structured HTML deck data matching HtmlDeckData"),
435
+ strict: z.boolean().default(false).describe("If true, warnings cause valid to be false")
436
+ });
437
+ function countWords(str) {
438
+ if (!str) return 0;
439
+ return str.trim().split(/\s+/).filter(Boolean).length;
440
+ }
441
+ function validateHtmlSlideDeck(deck, strict = false) {
442
+ const issues = [];
443
+ const suggestions = [];
444
+ const slides = deck.slides || [];
445
+ const slideCount = slides.length;
446
+ if (slideCount === 0) {
447
+ return {
448
+ success: false,
449
+ valid: false,
450
+ score: 0,
451
+ format: "html",
452
+ slideCount: 0,
453
+ notesCoveragePercent: 0,
454
+ issues: [{
455
+ slideIndex: 0,
456
+ severity: "error",
457
+ rule: "EMPTY_DECK",
458
+ message: "Presentation deck contains no slides."
459
+ }],
460
+ suggestions: ["Add at least one slide (e.g. hero-cover) to the deck."]
461
+ };
462
+ }
463
+ let notesCount = 0;
464
+ let hasCover = false;
465
+ let hasQuiz = false;
466
+ let hasSummary = false;
467
+ slides.forEach((slide, idx) => {
468
+ const slideNumber = idx + 1;
469
+ const layoutId = slide.layoutId;
470
+ const preset = HTML_SLIDE_PRESETS[layoutId];
471
+ if (!preset) {
472
+ issues.push({
473
+ slideIndex: slideNumber,
474
+ severity: "error",
475
+ rule: "INVALID_LAYOUT_PRESET",
476
+ message: `Unknown layoutId "${slide.layoutId}". Available presets: ${Object.keys(HTML_SLIDE_PRESETS).join(", ")}`
477
+ });
478
+ return;
479
+ }
480
+ if (preset.category === "cover" && idx === 0) hasCover = true;
481
+ if (preset.id === "checkpoint-quiz") hasQuiz = true;
482
+ if (preset.id === "summary-takeaways") hasSummary = true;
483
+ for (const slotDef of preset.slots) {
484
+ if (slotDef.required) {
485
+ const val = slide.slots?.[slotDef.name];
486
+ if (val === void 0 || val === null || typeof val === "string" && val.trim() === "") {
487
+ issues.push({
488
+ slideIndex: slideNumber,
489
+ severity: "error",
490
+ rule: "MISSING_REQUIRED_SLOT",
491
+ message: `Slide ${slideNumber} (${layoutId}) is missing required slot "${slotDef.name}" (${slotDef.label}).`
492
+ });
493
+ }
494
+ }
495
+ }
496
+ const slots = slide.slots || {};
497
+ for (const [key, val] of Object.entries(slots)) {
498
+ if (typeof val === "string") {
499
+ const words = countWords(val);
500
+ if (key !== "code" && words > 50) {
501
+ issues.push({
502
+ slideIndex: slideNumber,
503
+ severity: "warning",
504
+ rule: "ZERO_SCROLL_WORD_BUDGET",
505
+ message: `Slot "${key}" on slide ${slideNumber} has ${words} words. Recommended max is 35-40 words to prevent vertical scrolling.`
506
+ });
507
+ }
508
+ } else if (Array.isArray(val)) {
509
+ if (val.length > 5) {
510
+ issues.push({
511
+ slideIndex: slideNumber,
512
+ severity: "warning",
513
+ rule: "EXCESSIVE_LIST_ITEMS",
514
+ message: `List slot "${key}" on slide ${slideNumber} has ${val.length} items. Keep to 3-4 items for optimal readability.`
515
+ });
516
+ }
517
+ val.forEach((item, itemIdx) => {
518
+ if (typeof item === "string") {
519
+ const w = countWords(item);
520
+ if (w > 20) {
521
+ issues.push({
522
+ slideIndex: slideNumber,
523
+ severity: "warning",
524
+ rule: "BULLET_WORD_BUDGET",
525
+ message: `Bullet #${itemIdx + 1} in "${key}" on slide ${slideNumber} is ${w} words. Keep bullet points concise (< 15 words).`
526
+ });
527
+ }
528
+ }
529
+ });
530
+ }
531
+ }
532
+ const rawNotes = Array.isArray(slide.notes) ? slide.notes.join("\n") : typeof slide.notes === "string" ? slide.notes : "";
533
+ if (rawNotes && rawNotes.trim().length > 0) {
534
+ notesCount++;
535
+ const notes = rawNotes.trim();
536
+ const hasQuestion = notes.includes("?") || /cold-?call|question/i.test(notes);
537
+ const hasTip = /scaffold|tip|analogy|hint/i.test(notes);
538
+ if (!hasQuestion || !hasTip) {
539
+ issues.push({
540
+ slideIndex: slideNumber,
541
+ severity: "warning",
542
+ rule: "INCOMPLETE_PRESENTER_NOTES",
543
+ message: `Presenter notes for slide ${slideNumber} should follow the 3-part contract: Talk Track, Cold-Call Question, and Scaffolding Tip.`
544
+ });
545
+ }
546
+ } else {
547
+ issues.push({
548
+ slideIndex: slideNumber,
549
+ severity: "error",
550
+ rule: "MISSING_PRESENTER_NOTES",
551
+ message: `Slide ${slideNumber} is missing presenter notes. 100% presenter notes coverage is required.`
552
+ });
553
+ }
554
+ });
555
+ if (slideCount >= 3 && !hasCover) {
556
+ issues.push({
557
+ slideIndex: 1,
558
+ severity: "warning",
559
+ rule: "MISSING_HERO_COVER",
560
+ message: 'Slide 1 should ideally use the "hero-cover" layout preset to introduce the topic and objectives.'
561
+ });
562
+ }
563
+ if (slideCount >= 6 && !hasQuiz) {
564
+ issues.push({
565
+ slideIndex: Math.floor(slideCount / 2),
566
+ severity: "warning",
567
+ rule: "MISSING_FORMATIVE_CHECKPOINT",
568
+ message: `Deck has ${slideCount} slides but lacks a "checkpoint-quiz" for mid-lesson active recall.`
569
+ });
570
+ }
571
+ if (slideCount >= 4 && !hasSummary) {
572
+ issues.push({
573
+ slideIndex: slideCount,
574
+ severity: "warning",
575
+ rule: "MISSING_SUMMARY_SLIDE",
576
+ message: 'Deck lacks a "summary-takeaways" wrap-up slide at the conclusion of the presentation.'
577
+ });
578
+ }
579
+ const notesCoveragePercent = Math.round(notesCount / slideCount * 100);
580
+ const errorCount = issues.filter((i) => i.severity === "error").length;
581
+ const warningCount = issues.filter((i) => i.severity === "warning").length;
582
+ let score = 100 - errorCount * 15 - warningCount * 4;
583
+ score = Math.max(0, Math.min(100, score));
584
+ const valid = strict ? issues.length === 0 : errorCount === 0;
585
+ if (errorCount > 0) {
586
+ suggestions.push(`Resolve ${errorCount} blocking error(s) before presenting or publishing.`);
587
+ }
588
+ if (notesCoveragePercent < 100) {
589
+ suggestions.push(`Increase presenter notes coverage from ${notesCoveragePercent}% to 100%.`);
590
+ }
591
+ if (!hasQuiz && slideCount >= 6) {
592
+ suggestions.push("Add an interactive checkpoint quiz around the midpoint of the lesson.");
593
+ }
594
+ return {
595
+ success: true,
596
+ valid,
597
+ score,
598
+ format: "html",
599
+ slideCount,
600
+ notesCoveragePercent,
601
+ issues,
602
+ suggestions
603
+ };
604
+ }
605
+ function validateMarkdownSlideDeck(markdown, strict = false) {
606
+ const issues = [];
607
+ const suggestions = [];
608
+ if (!markdown || markdown.trim().length === 0) {
609
+ return {
610
+ success: false,
611
+ valid: false,
612
+ score: 0,
613
+ format: "markdown",
614
+ slideCount: 0,
615
+ notesCoveragePercent: 0,
616
+ issues: [{
617
+ slideIndex: 0,
618
+ severity: "error",
619
+ rule: "EMPTY_MARKDOWN",
620
+ message: "Markdown slide presentation is empty."
621
+ }],
622
+ suggestions: ['Provide Markdown slide content delimited by "---".']
623
+ };
624
+ }
625
+ const { slides: rawSlides } = splitMarkdownSlides(markdown);
626
+ const activeSlides = rawSlides.filter((s) => s.trim().length > 0);
627
+ const slideCount = activeSlides.length;
628
+ if (slideCount === 0) {
629
+ return {
630
+ success: false,
631
+ valid: false,
632
+ score: 0,
633
+ format: "markdown",
634
+ slideCount: 0,
635
+ notesCoveragePercent: 0,
636
+ issues: [{
637
+ slideIndex: 0,
638
+ severity: "error",
639
+ rule: "EMPTY_MARKDOWN",
640
+ message: "No slide content detected after stripping frontmatter."
641
+ }],
642
+ suggestions: ['Add slide content separated by "---".']
643
+ };
644
+ }
645
+ let notesCount = 0;
646
+ activeSlides.forEach((slideContent, idx) => {
647
+ const slideNumber = idx + 1;
648
+ const trimmed = slideContent.trim();
649
+ const notesMatch = trimmed.match(/<!--\s*(?:Presenter Notes:?[\s\S]*?|[\s\S]*?notes[\s\S]*?)-->/i);
650
+ if (notesMatch) {
651
+ notesCount++;
652
+ const noteBody = notesMatch[0];
653
+ const hasQuestion = noteBody.includes("?") || /cold-?call|question/i.test(noteBody);
654
+ const hasTip = /scaffold|tip|analogy|hint/i.test(noteBody);
655
+ if (!hasQuestion || !hasTip) {
656
+ issues.push({
657
+ slideIndex: slideNumber,
658
+ severity: "warning",
659
+ rule: "INCOMPLETE_PRESENTER_NOTES",
660
+ message: `Presenter notes on slide ${slideNumber} should include Talk Track, a Cold-Call Question, and a Scaffolding Tip.`
661
+ });
662
+ }
663
+ } else {
664
+ issues.push({
665
+ slideIndex: slideNumber,
666
+ severity: "error",
667
+ rule: "MISSING_PRESENTER_NOTES",
668
+ message: `Slide ${slideNumber} is missing presenter notes comments (<!-- Presenter Notes: ... -->).`
669
+ });
670
+ }
671
+ const codeBlockTokens = trimmed.match(/```/g);
672
+ if (codeBlockTokens && codeBlockTokens.length % 2 !== 0) {
673
+ issues.push({
674
+ slideIndex: slideNumber,
675
+ severity: "error",
676
+ rule: "UNCLOSED_CODE_BLOCK",
677
+ message: `Slide ${slideNumber} contains unclosed code fence backticks (\`\`\`).`
678
+ });
679
+ }
680
+ const cleanBody = trimmed.replace(/<!--[\s\S]*?-->/g, "").replace(/```[\s\S]*?```/g, "");
681
+ const words = countWords(cleanBody);
682
+ if (words > 100) {
683
+ issues.push({
684
+ slideIndex: slideNumber,
685
+ severity: "warning",
686
+ rule: "ZERO_SCROLL_WORD_BUDGET",
687
+ message: `Slide ${slideNumber} body has ${words} words. Keep within 40-70 words per slide to prevent vertical scroll.`
688
+ });
689
+ }
690
+ });
691
+ const notesCoveragePercent = Math.round(notesCount / slideCount * 100);
692
+ const errorCount = issues.filter((i) => i.severity === "error").length;
693
+ const warningCount = issues.filter((i) => i.severity === "warning").length;
694
+ let score = 100 - errorCount * 15 - warningCount * 4;
695
+ score = Math.max(0, Math.min(100, score));
696
+ const valid = strict ? issues.length === 0 : errorCount === 0;
697
+ return {
698
+ success: true,
699
+ valid,
700
+ score,
701
+ format: "markdown",
702
+ slideCount,
703
+ notesCoveragePercent,
704
+ issues,
705
+ suggestions
706
+ };
707
+ }
708
+ function executeValidateSlideDeck(input) {
709
+ const format = input.format || "auto";
710
+ if (format === "html" || format === "auto" && input.htmlDeck && input.htmlDeck.slides) {
711
+ return validateHtmlSlideDeck(input.htmlDeck || { slides: [] }, input.strict);
712
+ }
713
+ if (format === "markdown" || format === "auto" && input.markdown) {
714
+ return validateMarkdownSlideDeck(input.markdown || "", input.strict);
715
+ }
716
+ return {
717
+ success: false,
718
+ valid: false,
719
+ score: 0,
720
+ format: "html",
721
+ slideCount: 0,
722
+ notesCoveragePercent: 0,
723
+ issues: [{
724
+ slideIndex: 0,
725
+ severity: "error",
726
+ rule: "INVALID_INPUT",
727
+ message: "Neither htmlDeck nor markdown was supplied for slide deck validation."
728
+ }],
729
+ suggestions: ['Provide either "htmlDeck" object or "markdown" string in the validation parameters.']
730
+ };
731
+ }
732
+ var handleValidateSlideDeck = executeValidateSlideDeck;
414
733
  var listHtmlSlidePresetsSchema = z.object({
415
734
  category: z.enum(["all", "cover", "content", "split", "grid", "timeline", "callout", "assessment"]).optional().describe("Optional category filter for HTML layout presets")
416
735
  });
@@ -519,8 +838,8 @@ Instead of generating free-form HTML or brittle Markdown hacks, you MUST fill st
519
838
  - \`takeaways\` (string[]): 3 to 4 memorable bullet points
520
839
  - \`nextStep\` (string): Teaser for the next lesson or project
521
840
 
522
- ## Aesthetic Rules ("Anti-AI-Slop"):
523
- - **Brevity is King:** Each slide fits a 1920\xD71080 canvas. Keep sentences punchy. Never write dense paragraphs that overflow.
841
+ ## Aesthetic & Quality Invariants ("Anti-AI-Slop"):
842
+ - **Brevity is King (Zero-Scroll Invariant):** Each slide is calibrated for a 1920\xD71080 canvas. Maximum **35\u201340 words** per card or column; maximum **15 words** per bullet item. Never write dense multi-sentence paragraphs that cause vertical scrolling.
524
843
  - **Pedagogical Pacing:** Start with \`hero-cover\`, alternate between \`split-concept-code\`, \`two-columns-compare\` and \`three-cards-grid\`, insert a \`checkpoint-quiz\` midway, and finish with \`summary-takeaways\`.
525
844
  - **Theme Selection:**
526
845
  - \`blue-professional\`: General academic, clean engineering, trustworthy.
@@ -528,6 +847,24 @@ Instead of generating free-form HTML or brittle Markdown hacks, you MUST fill st
528
847
  - \`editorial-forest\`: Thoughtful design, literature, ethics, science.
529
848
  - \`studio\`: Minimalist product design, modern software.
530
849
  - \`monochrome\`: Pure high-contrast dark mode.
850
+
851
+ ## \u{1FA84} Step Reveal & Progressive Disclosure:
852
+ - The presentation shell supports sequential step reveal via mouse click or Space/Arrow keys.
853
+ - Bullet lists (\`points\`, \`col1Items\`, \`col2Items\`), cards in \`three-cards-grid\`, and steps in \`timeline-steps\` reveal progressively one by one before navigating to the next slide.
854
+ - In custom HTML slots, you can attach \`class="step-reveal"\`, \`data-step\`, \`data-reveal\`, or \`data-auto-reveal="true"\` on parent containers to enable click-by-click stepped appearance.
855
+
856
+ ## \u{1F399}\uFE0F Mandatory 3-Part Presenter Notes Contract:
857
+ Every single slide MUST include the \`notes\` property structured with these 3 explicit components:
858
+ 1. **Talk Track:** 2-3 sentences of exact conversational speaking script for the teacher/presenter.
859
+ 2. **Cold-Call Check Question:** 1 diagnostic question to check understanding with a named student or attendee.
860
+ 3. **Scaffolding Tip:** 1 intuitive analogy or troubleshooting hint in case learners struggle with the concept.
861
+
862
+ Example Notes:
863
+ \`\`\`markdown
864
+ Talk Track: Here we contrast synchronous blocking I/O with asynchronous event-driven handling. Notice how threads remain idle while waiting for network responses.
865
+ Cold-Call: "Jordan, looking at the left column, what happens to thread pool throughput when network latency quadruples?"
866
+ Scaffolding Tip: Compare it to ordering coffee at a counter (async buzzer) versus waiting at the register until the cup is brewed (sync blocking).
867
+ \`\`\`
531
868
  `;
532
869
 
533
870
  // src/ai/html/tools.ts
@@ -586,7 +923,10 @@ function handleCreateHtmlSlide(input) {
586
923
  }
587
924
  };
588
925
  }
926
+ var executeListHtmlSlidePresets = handleListHtmlSlidePresets;
927
+ var executeGenerateHtmlDeck = handleGenerateHtmlDeck;
928
+ var executeCreateHtmlSlide = handleCreateHtmlSlide;
589
929
 
590
- export { SLIDE_DESIGN_PROMPT_CONTRACT, SLIDE_HTML_PROMPT_CONTRACT, applySlideLayoutSchema, createHtmlSlideSchema, createSlideFromPresetSchema, executeApplySlideLayout, executeCreateSlideFromPreset, executeGenerateDeckOutline, executeListSlidePresets, executeUpdatePresenterNotes, generateDeckOutlineSchema, generateHtmlDeckSchema, handleCreateHtmlSlide, handleGenerateHtmlDeck, handleListHtmlSlidePresets, htmlSlideSlotDataSchema, listHtmlSlidePresetsSchema, listSlidePresetsSchema, updatePresenterNotesSchema };
930
+ export { SLIDE_DESIGN_PROMPT_CONTRACT, SLIDE_HTML_PROMPT_CONTRACT, applySlideLayoutSchema, createHtmlSlideSchema, createSlideFromPresetSchema, executeApplySlideLayout, executeCreateHtmlSlide, executeCreateSlideFromPreset, executeGenerateDeckOutline, executeGenerateHtmlDeck, executeListHtmlSlidePresets, executeListSlidePresets, executeUpdatePresenterNotes, executeValidateSlideDeck, generateDeckOutlineSchema, generateHtmlDeckSchema, handleCreateHtmlSlide, handleGenerateHtmlDeck, handleListHtmlSlidePresets, handleValidateSlideDeck, htmlSlideSlotDataSchema, listHtmlSlidePresetsSchema, listSlidePresetsSchema, updatePresenterNotesSchema, validateHtmlSlideDeck, validateMarkdownSlideDeck, validateSlideDeckSchema };
591
931
  //# sourceMappingURL=index.js.map
592
932
  //# sourceMappingURL=index.js.map