@thierrynakoa/fire-flow 12.2.1 → 13.0.1
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/CREDITS.md +25 -0
- package/DOMINION-FLOW-OVERVIEW.md +182 -38
- package/README.md +399 -455
- package/TROUBLESHOOTING.md +264 -264
- package/agents/fire-debugger.md +54 -0
- package/agents/fire-executor.md +1610 -1033
- package/agents/fire-fact-checker.md +1 -1
- package/agents/fire-planner.md +85 -17
- package/agents/fire-project-researcher.md +1 -1
- package/agents/fire-researcher.md +4 -22
- package/agents/{fire-phoenix-analyst.md → fire-resurrection-analyst.md} +394 -394
- package/agents/fire-reviewer.md +552 -499
- package/agents/fire-verifier.md +114 -19
- package/bin/cli.js +18 -101
- package/commands/fire-0-orient.md +2 -2
- package/commands/fire-1a-new.md +50 -15
- package/commands/fire-1c-setup.md +33 -5
- package/commands/fire-1d-discuss.md +87 -1
- package/commands/fire-2-plan.md +556 -527
- package/commands/fire-3-execute.md +2046 -1356
- package/commands/fire-4-verify.md +975 -906
- package/commands/fire-5-handoff.md +46 -5
- package/commands/fire-6-resume.md +2 -31
- package/commands/fire-add-new-skill.md +138 -19
- package/commands/fire-autonomous.md +14 -2
- package/commands/fire-complete-milestone.md +1 -1
- package/commands/fire-cost.md +179 -183
- package/commands/fire-debug.md +1 -6
- package/commands/fire-loop-resume.md +2 -2
- package/commands/fire-loop-stop.md +1 -1
- package/commands/fire-loop.md +2 -15
- package/commands/fire-map-codebase.md +1 -1
- package/commands/fire-migrate-database.md +548 -0
- package/commands/fire-new-milestone.md +1 -1
- package/commands/fire-reflect.md +1 -2
- package/commands/fire-research.md +142 -21
- package/commands/{fire-phoenix.md → fire-resurrect.md} +859 -603
- package/commands/fire-scaffold.md +297 -0
- package/commands/fire-search.md +1 -2
- package/commands/fire-security-scan.md +483 -484
- package/commands/fire-setup.md +359 -0
- package/commands/fire-skill.md +770 -0
- package/commands/fire-skills-diff.md +506 -506
- package/commands/fire-skills-history.md +388 -388
- package/commands/fire-skills-rollback.md +7 -7
- package/commands/fire-skills-sync.md +470 -470
- package/commands/fire-test.md +5 -5
- package/commands/fire-todos.md +1 -1
- package/commands/fire-update.md +5 -5
- package/commands/fire-validate-skills.md +282 -0
- package/commands/fire-vuln-scan.md +492 -493
- package/hooks/run-hook.sh +8 -8
- package/hooks/run-session-end.sh +7 -7
- package/hooks/session-end.sh +90 -90
- package/hooks/session-start.sh +1 -1
- package/package.json +4 -24
- package/plugin.json +7 -7
- package/references/autonomy-levels.md +235 -0
- package/references/behavioral-directives.md +95 -3
- package/references/blocker-tracking.md +1 -1
- package/references/circuit-breaker.md +93 -2
- package/references/context-engineering.md +227 -9
- package/references/honesty-protocols.md +70 -1
- package/references/issue-to-pr-pipeline.md +149 -150
- package/references/metrics-and-trends.md +1 -2
- package/references/research-improvements.md +4 -108
- package/references/sdlc-mapping.md +73 -0
- package/references/state-machine.md +151 -0
- package/skills-library/AVAILABLE_TOOLS_REFERENCE.md +333 -0
- package/skills-library/SKILLS-INDEX.md +57 -558
- package/skills-library/SKILLS_LIBRARY_INDEX.md +532 -0
- package/skills-library/_general/api-patterns/api-field-name-mismatch.md +107 -0
- package/skills-library/_general/api-patterns/streaming-command-timeout.md +122 -0
- package/skills-library/_general/api-patterns/streaming-proxy-cors-bypass.md +102 -0
- package/skills-library/_general/automation/settings-gui-generator.md +172 -0
- package/skills-library/_general/database-solutions/data-type-mapping-reference.md +181 -0
- package/skills-library/_general/database-solutions/mysql-limit-offset-string-coercion.md +102 -0
- package/skills-library/_general/database-solutions/mysql-to-pg-migration.md +195 -0
- package/skills-library/_general/database-solutions/orm-schema-portability.md +193 -0
- package/skills-library/_general/database-solutions/persistent-analysis-storage.md +207 -0
- package/skills-library/_general/database-solutions/pg-to-mysql-schema-migration-methodology.md +190 -0
- package/skills-library/_general/database-solutions/sql-dialect-compatibility-matrix.md +306 -0
- package/skills-library/_general/database-solutions/sqlite-to-pg-migration.md +219 -0
- package/skills-library/_general/frontend/canvas-bubble-animation-grouping.md +270 -0
- package/skills-library/_general/frontend/color-token-migration.md +112 -0
- package/skills-library/_general/frontend/framer-motion-layoutid-grouping.md +150 -0
- package/skills-library/_general/frontend/pyqt6-settings-dialog.md +191 -0
- package/skills-library/_general/frontend/react-flow-animated-layout-switching.md +101 -0
- package/skills-library/_general/frontend/react-hooks-order-debugging.md +141 -0
- package/skills-library/_general/frontend/redux-localstorage-auth-desync.md +126 -0
- package/skills-library/_general/frontend/safari-csp-theme-color-debugging.md +124 -0
- package/skills-library/_general/frontend/safari-sw-cache-poisoning.md +138 -0
- package/skills-library/_general/frontend/svg-sparkline-no-charting-library.md +131 -0
- package/skills-library/_general/growth-marketing/oss-daily-growth-intelligence.md +224 -0
- package/skills-library/_general/integrations/claude-code-local-mcp-integration.md +250 -0
- package/skills-library/_general/integrations/mcp-composite-tool-orchestration.md +200 -0
- package/skills-library/_general/methodology/AGENT_SDK_STANDALONE_TOOLING.md +181 -0
- package/skills-library/_general/methodology/AGENT_TEAMS_GUIDE.md +169 -0
- package/skills-library/_general/methodology/ALAS_STATEFUL_EXECUTION.md +207 -0
- package/skills-library/_general/methodology/AUTO_REVIEWER_SUBAGENT.md +211 -0
- package/skills-library/_general/methodology/CONSISTENCY_CHECK_AMBIGUITY_GATE.md +96 -0
- package/skills-library/_general/methodology/DEAD_ENDS_SHELF.md +4 -4
- package/skills-library/_general/methodology/DISTILL_NOT_DUMP.md +108 -0
- package/skills-library/_general/methodology/EXECUTION_PROGRESS_MONITOR.md +157 -0
- package/skills-library/_general/methodology/HIERARCHICAL_REVIEW_MARS.md +122 -0
- package/skills-library/_general/methodology/MCP_INTER_AGENT_BRIDGE.md +207 -0
- package/skills-library/_general/methodology/MERMAID_WIZARD_DIAGRAMS.md +77 -0
- package/skills-library/_general/methodology/MISSING_DIMENSION_DETECTOR.md +89 -0
- package/skills-library/_general/methodology/MULTI_AGENT_COORDINATION.md +397 -0
- package/skills-library/_general/methodology/OBSERVATION_MASKING.md +100 -0
- package/skills-library/_general/methodology/PHOENIX_REBUILD_METHODOLOGY.md +82 -11
- package/skills-library/_general/methodology/REVIEW_BACKTRACK_PANEL.md +140 -0
- package/skills-library/_general/methodology/REVIEW_FIX_LOOP.md +117 -0
- package/skills-library/_general/methodology/VOTING_VERDICT_ARBITRATION.md +155 -0
- package/skills-library/_general/methodology/ZERO_FRICTION_CLI_SETUP.md +2 -2
- package/skills-library/_general/methodology/dead-code-activation.md +123 -0
- package/skills-library/_general/methodology/debug-swarm-researcher-escape-hatch.md +240 -240
- package/skills-library/_general/methodology/shell-autonomous-loop-fixplan.md +1 -1
- package/skills-library/_general/patterns-standards/GOF_DESIGN_PATTERNS_FOR_AI_AGENTS.md +5 -5
- package/skills-library/_general/patterns-standards/cascading-failure-diagnosis.md +119 -0
- package/skills-library/_general/patterns-standards/domain-specific-layout-algorithms.md +209 -0
- package/skills-library/_general/patterns-standards/python-desktop-app-architecture.md +399 -0
- package/skills-library/_general/patterns-standards/realtime-monitoring-dashboard.md +457 -0
- package/skills-library/_general/patterns-standards/togglable-processing-pipeline.md +169 -0
- package/skills-library/_general/performance/liveclock-extraction.md +112 -0
- package/skills-library/_general/performance/ref-based-canvas-animation.md +117 -0
- package/skills-library/_general/performance/use-visible-interval.md +131 -0
- package/skills-library/_general/testing/playwright-firefox-withcredentials-auth-issue.md +104 -0
- package/skills-library/_quarantine/README.md +30 -0
- package/skills-library/api-patterns/BROADCAST_SCHEDULER_SHARED_EXECUTE_FUNCTION.md +150 -0
- package/skills-library/api-patterns/ERROR_RESPONSE_STANDARDS.md +145 -0
- package/skills-library/api-patterns/EXPRESS_ROUTE_ORDERING_MIDDLEWARE_INTERCEPTION.md +326 -0
- package/skills-library/api-patterns/PAGINATION_PATTERNS.md +137 -0
- package/skills-library/api-patterns/PODCAST_PROGRESS_TRACKING_THREE_ROOT_CAUSES.md +277 -0
- package/skills-library/api-patterns/RATE_LIMITING_TOGGLE.md +155 -0
- package/skills-library/api-patterns/graphql-content-queries.md +708 -0
- package/skills-library/appointment-scheduler-design.md +423 -0
- package/skills-library/automation/AUTO_POPULATE_COMPLETE_GUIDE.md +631 -0
- package/skills-library/automation/CC_WORKFLOW_STUDIO.md +83 -0
- package/skills-library/automation/CLAUDE_CODE_SWARM_MODE.md +95 -0
- package/skills-library/automation/DAEMON_TRIGGER_FILE_IPC.md +195 -0
- package/skills-library/automation/scheduled-content-publishing.md +608 -0
- package/skills-library/awesome-workflows/Blogging-Platform-Instructions/view_commands.md +25 -0
- package/skills-library/awesome-workflows/CREDENTIAL-SECURITY-WORKFLOW.md +109 -0
- package/skills-library/awesome-workflows/DEBUGGING-WORKFLOW.md +124 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/README.md +31 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/design-principles-example.md +129 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/design-review-agent.md +107 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/design-review-claude-md-snippet.md +24 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/design-review-slash-command.md +38 -0
- package/skills-library/awesome-workflows/PARALLEL-RESEARCH-WORKFLOW.md +89 -0
- package/skills-library/awesome-workflows/PHASE-EXECUTION-WORKFLOW.md +97 -0
- package/skills-library/awesome-workflows/SESSION-HANDOFF-WORKFLOW.md +116 -0
- package/skills-library/cms-patterns/content-branch-preview.md +515 -0
- package/skills-library/cms-patterns/inline-visual-editing.md +666 -0
- package/skills-library/cms-patterns/mdx-component-content.md +649 -0
- package/skills-library/cms-patterns/media-manager-abstraction.md +827 -0
- package/skills-library/cms-patterns/schema-driven-form-generator.md +838 -0
- package/skills-library/complexity-metrics/complexity-divider.md +707 -0
- package/skills-library/complexity-metrics/work-with-complexity.md +193 -0
- package/skills-library/creative-multimedia/animation-stack-guide.md +577 -0
- package/skills-library/creative-multimedia/audio-enhancement-pipeline.md +625 -0
- package/skills-library/creative-multimedia/content-repurposing-pipeline.md +1146 -0
- package/skills-library/creative-multimedia/data-visualization-generator.md +862 -0
- package/skills-library/creative-multimedia/doc-to-podcast-pipeline.md +2184 -0
- package/skills-library/creative-multimedia/ffmpeg-command-generator.md +405 -0
- package/skills-library/creative-multimedia/image-optimization-pipeline.md +605 -0
- package/skills-library/creative-multimedia/multi-format-content-generator.md +1759 -0
- package/skills-library/creative-multimedia/og-image-generator.md +635 -0
- package/skills-library/creative-multimedia/podcast-audio-composition.md +1355 -0
- package/skills-library/creative-multimedia/podcast-quality-evaluation.md +1452 -0
- package/skills-library/creative-multimedia/podcast-script-generation.md +1841 -0
- package/skills-library/creative-multimedia/svg-generation.md +750 -0
- package/skills-library/creative-multimedia/text-to-speech-provider-selector.md +1414 -0
- package/skills-library/creative-multimedia/transcription-pipeline-selector.md +677 -0
- package/skills-library/creative-multimedia/video-streaming-setup.md +559 -0
- package/skills-library/database-solutions/AI_RESPONSE_DATABASE_CACHING.md +520 -0
- package/skills-library/database-solutions/CONDITIONAL_SQL_MIGRATION_PATTERN.md +119 -0
- package/skills-library/database-solutions/DATABASE_COLUMN_NAME_MISMATCH.md +393 -0
- package/skills-library/database-solutions/DATABASE_SCHEMA.md +394 -0
- package/skills-library/database-solutions/DATABASE_SCHEMA_VERIFICATION_GUIDE.md +348 -0
- package/skills-library/database-solutions/DATABASE_STRATEGY.md +71 -0
- package/skills-library/database-solutions/ES_MODULE_SEED_SCRIPT_PATTERN.md +52 -0
- package/skills-library/database-solutions/MIGRATION_GUIDE.md +3 -0
- package/skills-library/database-solutions/PLPGSQL_VARIABLE_CONFLICT_FIX.md +208 -0
- package/skills-library/database-solutions/POSTGRESQL_JSONB_DOUBLE_STRINGIFY_FIX.md +245 -0
- package/skills-library/database-solutions/POSTGRESQL_LICENSE_TABLE_DESIGN.md +393 -0
- package/skills-library/database-solutions/POSTGRESQL_UUID_DOCUMENT_RAG_DUAL_SCOPE.md +732 -0
- package/skills-library/database-solutions/POSTGRES_SQL_TEMPLATE_BINDING_ERROR.md +240 -0
- package/skills-library/database-solutions/PRISMA_DB_PUSH_DATA_LOSS_PREVENTION.md +141 -0
- package/skills-library/database-solutions/PRODUCTION_QUERY_OPTIMIZATION_RESTART_FIX.md +389 -0
- package/skills-library/database-solutions/RLS_SECURITY_GUIDE.md +107 -0
- package/skills-library/database-solutions/SCHEMA_ENHANCEMENTS_GUIDE.md +373 -0
- package/skills-library/database-solutions/SCHEMA_MIGRATION_GUIDE.md +368 -0
- package/skills-library/database-solutions/SCHEMA_VERIFICATION_QUICK_REFERENCE.md +104 -0
- package/skills-library/database-solutions/ai-erd-generator.md +1213 -0
- package/skills-library/database-solutions/content-publishing-states.md +631 -0
- package/skills-library/database-solutions/database-schema-designer.md +522 -0
- package/skills-library/database-solutions/er-diagram-components.md +569 -0
- package/skills-library/database-solutions/er-to-ddl-mapping.md +1405 -0
- package/skills-library/database-solutions/erd-creator-textbook-research.md +433 -0
- package/skills-library/database-solutions/erd-react-flow-architecture.md +1965 -0
- package/skills-library/database-solutions/mariadb-aggregate-function-replacement.md +145 -0
- package/skills-library/database-solutions/normalization-validator.md +778 -0
- package/skills-library/database-solutions/postgres-full-text-search-content.md +494 -0
- package/skills-library/database-solutions/postgresql-to-mysql-runtime-translation.md +286 -0
- package/skills-library/database-solutions/regex-alternation-ordering-sql-types.md +92 -0
- package/skills-library/database-solutions/reserved-word-context-aware-quoting.md +142 -0
- package/skills-library/database-solutions/sql-ddl-generator.md +756 -0
- package/skills-library/database-solutions/supabase-connection-pooler-fix.md +102 -0
- package/skills-library/deployment-security/CPANEL_NODE_DEPLOYMENT.md +166 -0
- package/skills-library/deployment-security/DEPLOYMENT.md +275 -0
- package/skills-library/deployment-security/DEPLOYMENT_CHECKLIST.md +363 -0
- package/skills-library/deployment-security/DEPLOYMENT_PLAN.md +669 -0
- package/skills-library/deployment-security/KNEX_DATABASE_ABSTRACTION.md +444 -0
- package/skills-library/deployment-security/LICENSE_KEY_SYSTEM.md +206 -0
- package/skills-library/deployment-security/NODE18_DEPENDENCY_COMPATIBILITY.md +284 -0
- package/skills-library/deployment-security/PHP_INSTALLER_WIZARD_GUIDE.md +315 -0
- package/skills-library/deployment-security/PM2_ENVIRONMENT_VARIABLE_CACHING.md +256 -0
- package/skills-library/deployment-security/PM2_MEMORY_EXHAUSTION_FIX.md +370 -0
- package/skills-library/deployment-security/PRODUCTION_DEPLOYMENT_GUIDE.md +592 -0
- package/skills-library/deployment-security/PRODUCTION_HARDENING_DOCUMENTATION.md +307 -0
- package/skills-library/deployment-security/PRODUCTION_RECOVERY_CHERRY_PICK_PATTERN.md +202 -0
- package/skills-library/deployment-security/PYINSTALLER_CUDA_WHISPER_BUNDLING.md +236 -0
- package/skills-library/deployment-security/SECURITY.md +41 -0
- package/skills-library/deployment-security/SMTP_SSL_HOSTNAME_MISMATCH_SHARED_HOSTING.md +220 -0
- package/skills-library/deployment-security/SPA_SEO_OPTIMIZATION_CPANEL.md +200 -0
- package/skills-library/deployment-security/SUPABASE_EDGE_FUNCTIONS.md +338 -0
- package/skills-library/deployment-security/VERCEL_GITHUB_DEPLOYMENT_GUIDE.md +858 -0
- package/skills-library/deployment-security/VPS_DEPLOYMENT_READINESS.md +356 -0
- package/skills-library/deployment-security/deployment-changes-not-applying.md +241 -0
- package/skills-library/deployment-security/env-file-management-production-local.md +203 -0
- package/skills-library/deployment-security/express-secure-file-downloads.md +413 -0
- package/skills-library/deployment-security/react-production-deployment-desktop-guide.md +2011 -0
- package/skills-library/deployment-security/self-hosted-supabase-coolify-guide.md +1684 -0
- package/skills-library/deployment-security/unique-features-ai-strategy-plaid-security.md +1613 -0
- package/skills-library/deployment-security/vps-deployment.md +135 -0
- package/skills-library/document-processing/WORD_EXPORT_MARKDOWN_FORMATTING.md +482 -0
- package/skills-library/document-processing/document-ai-landingai-integration.md +677 -0
- package/skills-library/document-processing/express-secure-file-downloads-mern.md +413 -0
- package/skills-library/document-processing/express-secure-file-downloads.md +413 -0
- package/skills-library/document-processing/md-to-word-converter.md +318 -0
- package/skills-library/document-processing/pdf-forms-integration/README.md +101 -0
- package/skills-library/document-processing/pdf-forms-integration/SKILL.md +662 -0
- package/skills-library/ecommerce/ADMIN_PRODUCTS_GUIDE.md +428 -0
- package/skills-library/ecommerce/ECOMMERCE_API_REFERENCE.md +776 -0
- package/skills-library/ecommerce/ECOMMERCE_COMPLETION_SUMMARY.md +673 -0
- package/skills-library/ecommerce/ECOMMERCE_IMPLEMENTATION_GUIDE.md +729 -0
- package/skills-library/ecommerce/ECOMMERCE_QUICK_REFERENCE.md +521 -0
- package/skills-library/ecommerce/ECOMMERCE_TESTING_CHECKLIST.md +565 -0
- package/skills-library/ecommerce/ECOMMERCE_WORKFLOW_GUIDE.md +1059 -0
- package/skills-library/ecommerce/PRODUCT_CREATION_EXPANDED.md +522 -0
- package/skills-library/ecommerce/agentic-commerce-protocol.md +203 -0
- package/skills-library/ecommerce/cart-abandonment-recovery.md +236 -0
- package/skills-library/ecommerce/cart-architecture-patterns.md +300 -0
- package/skills-library/ecommerce/cart-item-count-indicator.md +264 -0
- package/skills-library/ecommerce/checkout-ux-conversion.md +227 -0
- package/skills-library/ecommerce/composable-commerce-selection.md +166 -0
- package/skills-library/ecommerce/ecommerce-analytics-patterns.md +167 -0
- package/skills-library/ecommerce/fraud-detection-patterns.md +179 -0
- package/skills-library/ecommerce/inventory-stock-management.md +270 -0
- package/skills-library/ecommerce/order-saga-state-machine.md +336 -0
- package/skills-library/ecommerce/payment-provider-abstraction.md +245 -0
- package/skills-library/ecommerce/pci-compliance-checklist.md +192 -0
- package/skills-library/ecommerce/refund-chargeback-handling.md +177 -0
- package/skills-library/ecommerce/shipping-carrier-integration.md +218 -0
- package/skills-library/ecommerce/webhook-idempotency-patterns.md +253 -0
- package/skills-library/excalidraw-diagrams/.github/workflows/ci.yml +558 -0
- package/skills-library/excalidraw-diagrams/.github/workflows/prompt-gallery.yml +448 -0
- package/skills-library/excalidraw-diagrams/.github/workflows/release.yml +42 -0
- package/skills-library/excalidraw-diagrams/.github/workflows/test-reusable-ci.yml +25 -0
- package/skills-library/excalidraw-diagrams/CLAUDE.md +57 -0
- package/skills-library/excalidraw-diagrams/LICENSE +21 -0
- package/skills-library/excalidraw-diagrams/README.md +178 -0
- package/skills-library/excalidraw-diagrams/SKILL.md +715 -0
- package/skills-library/form-solutions/BUTTON_TYPE_FORM_SUBMISSION.md +336 -0
- package/skills-library/form-solutions/FILLABLE_PDF_IMPLEMENTATION.md +226 -0
- package/skills-library/form-solutions/SURVEYJS_QUESTIONNAIRE_SYSTEM.md +367 -0
- package/skills-library/form-solutions/tiptap-minimal-setup.md +690 -0
- package/skills-library/frontend/scholarly-classification-bubble-map.md +149 -0
- package/skills-library/infrastructure/ci-cd-pipeline-builder.md +517 -0
- package/skills-library/infrastructure/observability-designer.md +264 -0
- package/skills-library/infrastructure/performance-profiler.md +621 -0
- package/skills-library/installer-wizard-patterns.md +249 -0
- package/skills-library/integrations/CLAUDE_CODE_TOKEN_ANALYTICS.md +160 -0
- package/skills-library/integrations/CONFIGURABLE_AI_PROVIDER_SELECTION.md +728 -0
- package/skills-library/integrations/SOCKET_IO_BROADCAST_ALL_VS_ROOM.md +141 -0
- package/skills-library/integrations/VIRTUAL_MEETINGS_IMPLEMENTATION.md +374 -0
- package/skills-library/integrations/WORDPRESS_LEARNDASH_DATA_RECOVERY.md +53 -0
- package/skills-library/integrations/YOUTUBE_API_SETUP.md +141 -0
- package/skills-library/integrations/YOUTUBE_BOOKMARKING_EXPLANATION.md +252 -0
- package/skills-library/integrations/YOUTUBE_BOOKMARKING_SOLUTION.md +268 -0
- package/skills-library/integrations/YOUTUBE_OAUTH_SETUP_GUIDE.md +200 -0
- package/skills-library/integrations/YOUTUBE_VIDEO_FIX_COMPLETE.md +192 -0
- package/skills-library/integrations/ai-ml/GEMINI_AI_RAG_PIPELINE_COMPLETE_GUIDE.md +195 -0
- package/skills-library/integrations/ai-ml/GEMINI_IMAGE_GENERATION_SETUP.md +64 -0
- package/skills-library/integrations/cloudflare/cloudflare-turnstile-debugging.md +202 -0
- package/skills-library/integrations/cloudflare/cloudflare-turnstile-implementation.md +476 -0
- package/skills-library/integrations/cloudflare-turnstile-debugging.md +202 -0
- package/skills-library/integrations/cloudflare-turnstile-implementation.md +476 -0
- package/skills-library/integrations/ghost-creator-monetization-pattern.md +454 -0
- package/skills-library/integrations/headless-cms-architecture.md +484 -0
- package/skills-library/integrations/headless-cms-stack-selection.md +183 -0
- package/skills-library/integrations/payload-cms-patterns.md +674 -0
- package/skills-library/integrations/realtimestt-openwakeword-cuda-windows.md +229 -0
- package/skills-library/integrations/rss-podcast-integration.md +300 -0
- package/skills-library/integrations/wordpress/WORDPRESS_LEARNDASH_DATA_RECOVERY.md +53 -0
- package/skills-library/integrations/youtube/YOUTUBE_API_SETUP.md +141 -0
- package/skills-library/integrations/youtube/YOUTUBE_BOOKMARKING_EXPLANATION.md +252 -0
- package/skills-library/integrations/youtube/YOUTUBE_BOOKMARKING_SOLUTION.md +268 -0
- package/skills-library/integrations/youtube/YOUTUBE_OAUTH_SETUP_GUIDE.md +200 -0
- package/skills-library/integrations/youtube/YOUTUBE_VIDEO_FIX_COMPLETE.md +192 -0
- package/skills-library/marketing/campaign-analytics.md +97 -0
- package/skills-library/marketing/content-creator.md +105 -0
- package/skills-library/marketing/marketing-strategy-pmm.md +94 -0
- package/skills-library/marketing/social-media-analyzer.md +81 -0
- package/skills-library/methodology/ADVANCED_ORCHESTRATION_PATTERNS.md +401 -0
- package/skills-library/methodology/AGENT_SELF_IMPROVEMENT_LOOP.md +179 -0
- package/skills-library/methodology/BREATH_BASED_PARALLEL_EXECUTION.md +1 -1
- package/skills-library/methodology/CLEANSING_CYCLE.md +358 -0
- package/skills-library/methodology/CONFIDENCE_ANNOTATION_PATTERN.md +143 -0
- package/skills-library/methodology/CRITICAL_PATTERNS_DOCUMENTATION_COMPLETE.md +204 -0
- package/skills-library/methodology/DELIVERABLES_SUMMARY.md +341 -0
- package/skills-library/methodology/DIFFICULTY_AWARE_AGENT_ROUTING.md +252 -0
- package/skills-library/methodology/EVOLUTIONARY_SKILL_SYNTHESIS.md +219 -0
- package/skills-library/methodology/GLOMERULUS_DECISION_GATE.md +223 -0
- package/skills-library/methodology/HIBERNATION_SYSTEM.md +231 -0
- package/skills-library/methodology/INSTRUMENTATION_OVER_RESTRICTION.md +192 -0
- package/skills-library/methodology/MASTER_COMPLETION_SUMMARY.md +444 -0
- package/skills-library/methodology/MASTER_SESSION_COMPLETION.md +743 -0
- package/skills-library/methodology/MERN_QUICK_REFERENCE.md +358 -0
- package/skills-library/methodology/ORGAN_AGENT_MAPPING.md +177 -0
- package/skills-library/methodology/PARALLEL_WAVE_BASED_REFACTORING.md +440 -0
- package/skills-library/methodology/QUICK_REFERENCE.md +358 -0
- package/skills-library/methodology/SDFT_ONPOLICY_SELF_DISTILLATION.md +186 -0
- package/skills-library/methodology/SELF_QUESTIONING_TASK_GENERATION.md +270 -0
- package/skills-library/methodology/SESSION_COMPLETION_SUMMARY.md +304 -0
- package/skills-library/methodology/SESSION_SUMMARY.md +432 -0
- package/skills-library/methodology/WARRIOR_WORKFLOW_DEBUGGING_PROTOCOL.md +252 -0
- package/skills-library/methodology/tech-debt-tracker.md +570 -0
- package/skills-library/parallel-debug/SKILL.md +60 -0
- package/skills-library/patterns-standards/API_PATTERN_FIX_SUMMARY.md +236 -0
- package/skills-library/patterns-standards/BATCH_OPERATIONS_WITH_PROGRESS_MODAL.md +362 -0
- package/skills-library/patterns-standards/CRITICAL_CODING_PATTERNS.md +639 -0
- package/skills-library/patterns-standards/DARK_MODE_MODAL_VISIBILITY.md +258 -0
- package/skills-library/patterns-standards/ERROR_RESILIENCE_IMPLEMENTATION.md +375 -0
- package/skills-library/patterns-standards/ES_MODULE_IMPORT_HOISTING_DOTENV.md +298 -0
- package/skills-library/patterns-standards/NESTED_BACKDROP_FILTER_CSS_ARTIFACT_FIX.md +76 -0
- package/skills-library/patterns-standards/ORDERED_DETECTOR_PIPELINE_GRACEFUL_FALLBACK.md +333 -0
- package/skills-library/patterns-standards/PHASE_IMPORT_ERROR_DEBUGGING.md +271 -0
- package/skills-library/patterns-standards/PYNPUT_GLOBAL_HOTKEY_VK_MATCHING.md +252 -0
- package/skills-library/patterns-standards/REACT_USEEFFECT_CASCADE_RESET_FIX.md +132 -0
- package/skills-library/patterns-standards/SUBMENU_HOVER_DROPDOWN_PATTERN.md +225 -0
- package/skills-library/patterns-standards/TAILWIND_TEXT_VISIBILITY_OVERRIDE.md +322 -0
- package/skills-library/patterns-standards/THEME_AWARE_CSS_VARIABLES_PATTERN.md +209 -0
- package/skills-library/patterns-standards/THEME_USER_OBJECT_PROPERTY_NAMING.md +194 -0
- package/skills-library/patterns-standards/TOOLTIP_BLOCKING_CLICKS_FIX.md +267 -0
- package/skills-library/patterns-standards/claude-code-plugin-structure.md +235 -0
- package/skills-library/patterns-standards/react-i18next-setup.md +429 -0
- package/skills-library/patterns-standards/thesys-c1-generative-ui-integration.md +967 -0
- package/skills-library/plugin-development/CLAUDE_CODE_COMMAND_REGISTRATION_SILENT_FAILURE.md +315 -0
- package/skills-library/plugin-development/plugin-command-namespace-vs-global.md +390 -0
- package/skills-library/plugin-development/plugin-doc-auto-generation.md +172 -0
- package/skills-library/security/GITHUB_REPO_SECURITY_AUDIT.md +115 -0
- package/skills-library/security/admin-deletion-safety.md +396 -0
- package/skills-library/security/application-vuln-patterns.md +477 -0
- package/skills-library/security/env-secrets-manager.md +686 -0
- package/skills-library/security/secure-ai-application-templates.md +347 -0
- package/skills-library/security/sql-injection-prevention-postgresjs.md +151 -0
- package/skills-library/supabase-connection-pooler-fix.md +102 -0
- package/skills-library/system-context/POWERSHELL_BASH_INTEROP.md +82 -0
- package/skills-library/system-context/SERVICE_LIFECYCLE_MANAGEMENT.md +119 -0
- package/skills-library/system-context/SKILL.md +40 -0
- package/skills-library/system-context/WINDOWS_DEV_ENVIRONMENT.md +73 -0
- package/skills-library/testing/E2E_PLAYWRIGHT_PATTERNS.md +99 -0
- package/skills-library/testing/INTEGRATION_TEST_STRATEGY.md +82 -0
- package/skills-library/testing/RED_GREEN_BUGFIX_GATE.md +203 -0
- package/skills-library/testing/TEST_DATA_MANAGEMENT.md +69 -0
- package/skills-library/testing/VITEST_UNIT_TEST_PATTERNS.md +75 -0
- package/skills-library/testing/playwright-api-security-tests.md +202 -0
- package/skills-library/toolbox/SKILL.md +84 -0
- package/skills-library/toolbox/code-graph-and-web-scraping-mcps.md +237 -0
- package/skills-library/ui-ux-pro-max/ACCESSIBILITY_ESSENTIALS.md +115 -0
- package/skills-library/ui-ux-pro-max/DESIGN_SYSTEM_SCAFFOLDING.md +133 -0
- package/skills-library/ui-ux-pro-max/RESPONSIVE_LAYOUT_PATTERNS.md +119 -0
- package/skills-library/ui-ux-pro-max/SKILL.md +386 -0
- package/skills-library/ui-ux-pro-max/data/charts.csv +26 -0
- package/skills-library/ui-ux-pro-max/data/colors.csv +97 -0
- package/skills-library/ui-ux-pro-max/data/icons.csv +101 -0
- package/skills-library/ui-ux-pro-max/data/landing.csv +31 -0
- package/skills-library/ui-ux-pro-max/data/products.csv +97 -0
- package/skills-library/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/skills-library/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/skills-library/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/skills-library/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/skills-library/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/skills-library/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/skills-library/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/skills-library/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/skills-library/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/skills-library/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/skills-library/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/skills-library/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/skills-library/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/skills-library/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/skills-library/ui-ux-pro-max/data/styles.csv +68 -0
- package/skills-library/ui-ux-pro-max/data/typography.csv +58 -0
- package/skills-library/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/skills-library/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/skills-library/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/skills-library/wordpress-style-theme-components.md +1526 -0
- package/templates/ASSUMPTIONS.md +1 -1
- package/templates/DECISION_LOG.md +0 -1
- package/templates/phase-prompt.md +1 -1
- package/templates/phoenix-comparison.md +6 -6
- package/templates/skill-api-integration.md +106 -0
- package/templates/skill-architecture-pattern.md +92 -0
- package/templates/skill-debug-pattern.md +98 -0
- package/templates/skill-devops-recipe.md +107 -0
- package/templates/skill-general.md +65 -0
- package/templates/skill-ui-component.md +113 -0
- package/tools/uat-runner.py +179 -0
- package/version.json +7 -3
- package/workflows/handoff-session.md +2 -2
- package/workflows/new-project.md +2 -2
- package/workflows/plan-phase.md +1 -1
- package/.claude-plugin/plugin.json +0 -64
- package/skills-library/_general/methodology/LIVE_BREADCRUMB_PROTOCOL.md +0 -242
- package/skills-library/_general/methodology/llm-judge-memory-crud.md +0 -241
- package/skills-library/methodology/REFLEXION_MEMORY_PATTERN.md +0 -183
- package/skills-library/methodology/RESEARCH_BACKED_WORKFLOW_UPGRADE.md +0 -263
- package/skills-library/methodology/SABBATH_REST_PATTERN.md +0 -267
- package/skills-library/methodology/STONE_AND_SCAFFOLD.md +0 -220
- package/skills-library/specialists/api-architecture/api-designer.md +0 -49
- package/skills-library/specialists/api-architecture/graphql-architect.md +0 -49
- package/skills-library/specialists/api-architecture/mcp-developer.md +0 -51
- package/skills-library/specialists/api-architecture/microservices-architect.md +0 -50
- package/skills-library/specialists/api-architecture/websocket-engineer.md +0 -48
- package/skills-library/specialists/backend/django-expert.md +0 -52
- package/skills-library/specialists/backend/fastapi-expert.md +0 -52
- package/skills-library/specialists/backend/laravel-specialist.md +0 -52
- package/skills-library/specialists/backend/nestjs-expert.md +0 -51
- package/skills-library/specialists/backend/rails-expert.md +0 -53
- package/skills-library/specialists/backend/spring-boot-engineer.md +0 -56
- package/skills-library/specialists/data-ml/fine-tuning-expert.md +0 -48
- package/skills-library/specialists/data-ml/ml-pipeline.md +0 -47
- package/skills-library/specialists/data-ml/pandas-pro.md +0 -47
- package/skills-library/specialists/data-ml/rag-architect.md +0 -51
- package/skills-library/specialists/data-ml/spark-engineer.md +0 -47
- package/skills-library/specialists/frontend/angular-architect.md +0 -52
- package/skills-library/specialists/frontend/flutter-expert.md +0 -51
- package/skills-library/specialists/frontend/nextjs-developer.md +0 -54
- package/skills-library/specialists/frontend/react-native-expert.md +0 -50
- package/skills-library/specialists/frontend/vue-expert.md +0 -51
- package/skills-library/specialists/infrastructure/chaos-engineer.md +0 -74
- package/skills-library/specialists/infrastructure/cloud-architect.md +0 -70
- package/skills-library/specialists/infrastructure/database-optimizer.md +0 -64
- package/skills-library/specialists/infrastructure/devops-engineer.md +0 -70
- package/skills-library/specialists/infrastructure/kubernetes-specialist.md +0 -52
- package/skills-library/specialists/infrastructure/monitoring-expert.md +0 -70
- package/skills-library/specialists/infrastructure/sre-engineer.md +0 -70
- package/skills-library/specialists/infrastructure/terraform-engineer.md +0 -51
- package/skills-library/specialists/languages/cpp-pro.md +0 -74
- package/skills-library/specialists/languages/csharp-developer.md +0 -69
- package/skills-library/specialists/languages/dotnet-core-expert.md +0 -54
- package/skills-library/specialists/languages/golang-pro.md +0 -51
- package/skills-library/specialists/languages/java-architect.md +0 -49
- package/skills-library/specialists/languages/javascript-pro.md +0 -68
- package/skills-library/specialists/languages/kotlin-specialist.md +0 -68
- package/skills-library/specialists/languages/php-pro.md +0 -49
- package/skills-library/specialists/languages/python-pro.md +0 -52
- package/skills-library/specialists/languages/react-expert.md +0 -51
- package/skills-library/specialists/languages/rust-engineer.md +0 -50
- package/skills-library/specialists/languages/sql-pro.md +0 -56
- package/skills-library/specialists/languages/swift-expert.md +0 -69
- package/skills-library/specialists/languages/typescript-pro.md +0 -51
- package/skills-library/specialists/platform/atlassian-mcp.md +0 -52
- package/skills-library/specialists/platform/embedded-systems.md +0 -53
- package/skills-library/specialists/platform/game-developer.md +0 -53
- package/skills-library/specialists/platform/salesforce-developer.md +0 -53
- package/skills-library/specialists/platform/shopify-expert.md +0 -49
- package/skills-library/specialists/platform/wordpress-pro.md +0 -49
- package/skills-library/specialists/quality/code-documenter.md +0 -51
- package/skills-library/specialists/quality/code-reviewer.md +0 -67
- package/skills-library/specialists/quality/debugging-wizard.md +0 -51
- package/skills-library/specialists/quality/fullstack-guardian.md +0 -51
- package/skills-library/specialists/quality/legacy-modernizer.md +0 -50
- package/skills-library/specialists/quality/playwright-expert.md +0 -65
- package/skills-library/specialists/quality/spec-miner.md +0 -56
- package/skills-library/specialists/quality/test-master.md +0 -65
- package/skills-library/specialists/security/secure-code-guardian.md +0 -55
- package/skills-library/specialists/security/security-reviewer.md +0 -53
- package/skills-library/specialists/workflow/architecture-designer.md +0 -53
- package/skills-library/specialists/workflow/cli-developer.md +0 -70
- package/skills-library/specialists/workflow/feature-forge.md +0 -65
- package/skills-library/specialists/workflow/prompt-engineer.md +0 -54
- package/skills-library/specialists/workflow/the-fool.md +0 -62
- /package/skills-library/{performance → _general/performance}/cache-augmented-generation.md +0 -0
- /package/skills-library/{debugging → parallel-debug}/FAILURE_TAXONOMY_CLASSIFICATION.md +0 -0
- /package/skills-library/{debugging → parallel-debug}/THREE_AGENT_HYPOTHESIS_DEBUGGING.md +0 -0
|
@@ -0,0 +1,1759 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: multi-format-content-generator
|
|
3
|
+
category: creative-multimedia
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
contributed: 2026-03-10
|
|
6
|
+
contributor: dominion-flow-research
|
|
7
|
+
last_updated: 2026-03-10
|
|
8
|
+
tags: [content-generation, multi-format, notebooklm, slides, flashcards, quiz, podcast, repurposing]
|
|
9
|
+
difficulty: medium
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Multi-Format Content Generator
|
|
13
|
+
|
|
14
|
+
## Problem Solved
|
|
15
|
+
|
|
16
|
+
Generating multiple content formats from a single source document set. One upload produces a podcast script, slide deck, flashcards, quiz questions, summaries, FAQs, infographic data, and a study guide — all grounded exclusively in the source material. This is the "NotebookLM pattern": a shared understanding layer fans out to format-specific generators, ensuring every output traces back to an exact source passage.
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
- Converting sermon recordings or transcripts into a full week of ministry content
|
|
21
|
+
- Transforming research papers, reports, or books into multi-format learning materials
|
|
22
|
+
- Building course content from instructor-uploaded sources (the LMS use case)
|
|
23
|
+
- Creating study aids (flashcards, quizzes) from any document collection
|
|
24
|
+
- Generating presentation slides from written content
|
|
25
|
+
- Producing podcast scripts from articles, whitepapers, or meeting notes
|
|
26
|
+
- Repurposing Bible study material into multiple engagement formats
|
|
27
|
+
|
|
28
|
+
## Architecture Overview
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
┌─────────────────────────────────────────────────────────┐
|
|
32
|
+
│ DOCUMENT SOURCES │
|
|
33
|
+
│ PDF | DOCX | Transcript | YouTube | Audio | Markdown │
|
|
34
|
+
└──────────────────────┬──────────────────────────────────┘
|
|
35
|
+
│
|
|
36
|
+
▼
|
|
37
|
+
┌─────────────────────────────────────────────────────────┐
|
|
38
|
+
│ SHARED UNDERSTANDING LAYER │
|
|
39
|
+
│ │
|
|
40
|
+
│ 1. Parse & Chunk Documents │
|
|
41
|
+
│ 2. Extract Key Concepts, Definitions, Relationships │
|
|
42
|
+
│ 3. Build Structured Knowledge Representation │
|
|
43
|
+
│ 4. RAG Embedding (Gemini text-embedding-004) │
|
|
44
|
+
│ 5. Source Linking (every fact → exact passage) │
|
|
45
|
+
└──────────────────────┬──────────────────────────────────┘
|
|
46
|
+
│
|
|
47
|
+
┌─────────────┼─────────────┐
|
|
48
|
+
│ │ │
|
|
49
|
+
▼ ▼ ▼
|
|
50
|
+
┌─────────────┐ ┌───────────┐ ┌───────────┐
|
|
51
|
+
│ PODCAST │ │ SLIDES │ │ FLASHCARDS│
|
|
52
|
+
│ Script │ │ Deck │ │ (Anki) │
|
|
53
|
+
└─────────────┘ └───────────┘ └───────────┘
|
|
54
|
+
│ │ │
|
|
55
|
+
▼ ▼ ▼
|
|
56
|
+
┌─────────────┐ ┌───────────┐ ┌───────────┐
|
|
57
|
+
│ QUIZ │ │ SUMMARY │ │ FAQ │
|
|
58
|
+
│ Questions │ │ S / M / L │ │ │
|
|
59
|
+
└─────────────┘ └───────────┘ └───────────┘
|
|
60
|
+
│ │
|
|
61
|
+
▼ ▼
|
|
62
|
+
┌─────────────┐ ┌───────────┐
|
|
63
|
+
│ INFOGRAPHIC │ │ STUDY │
|
|
64
|
+
│ Data │ │ Guide │
|
|
65
|
+
└─────────────┘ └───────────┘
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The key insight: **parse once, generate many**. The Shared Understanding Layer does the expensive work (parsing, chunking, embedding, extraction). Each format generator receives the same `DocumentKnowledge` object and transforms it according to format-specific rules.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 1. Shared Understanding Layer
|
|
73
|
+
|
|
74
|
+
### Document Parsing
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { promises as fs } from 'fs';
|
|
78
|
+
import path from 'path';
|
|
79
|
+
|
|
80
|
+
// ─── Source Types ────────────────────────────────────────────────────────────
|
|
81
|
+
|
|
82
|
+
interface DocumentSource {
|
|
83
|
+
type: 'pdf' | 'docx' | 'markdown' | 'transcript' | 'youtube' | 'text';
|
|
84
|
+
path?: string; // File path for local files
|
|
85
|
+
url?: string; // URL for YouTube or web sources
|
|
86
|
+
content?: string; // Raw text content (if already extracted)
|
|
87
|
+
metadata: {
|
|
88
|
+
title: string;
|
|
89
|
+
author?: string;
|
|
90
|
+
date?: string;
|
|
91
|
+
tags?: string[];
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface DocumentChunk {
|
|
96
|
+
id: string;
|
|
97
|
+
text: string;
|
|
98
|
+
sourceId: string;
|
|
99
|
+
sourceTitle: string;
|
|
100
|
+
pageNumber?: number;
|
|
101
|
+
sectionTitle?: string;
|
|
102
|
+
startOffset: number;
|
|
103
|
+
endOffset: number;
|
|
104
|
+
embedding?: number[]; // Gemini text-embedding-004 vector
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ─── Extraction per Source Type ──────────────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
async function extractText(source: DocumentSource): Promise<string> {
|
|
110
|
+
switch (source.type) {
|
|
111
|
+
case 'pdf': {
|
|
112
|
+
const pdfParse = (await import('pdf-parse')).default;
|
|
113
|
+
const buffer = await fs.readFile(source.path!);
|
|
114
|
+
const result = await pdfParse(buffer);
|
|
115
|
+
return result.text;
|
|
116
|
+
}
|
|
117
|
+
case 'docx': {
|
|
118
|
+
const mammoth = await import('mammoth');
|
|
119
|
+
const result = await mammoth.extractRawText({ path: source.path! });
|
|
120
|
+
return result.value;
|
|
121
|
+
}
|
|
122
|
+
case 'markdown': {
|
|
123
|
+
return await fs.readFile(source.path!, 'utf-8');
|
|
124
|
+
}
|
|
125
|
+
case 'youtube': {
|
|
126
|
+
const { YoutubeTranscript } = await import('youtube-transcript');
|
|
127
|
+
const segments = await YoutubeTranscript.fetchTranscript(source.url!);
|
|
128
|
+
return segments.map(s => s.text).join(' ');
|
|
129
|
+
}
|
|
130
|
+
case 'transcript':
|
|
131
|
+
case 'text': {
|
|
132
|
+
return source.content ?? await fs.readFile(source.path!, 'utf-8');
|
|
133
|
+
}
|
|
134
|
+
default:
|
|
135
|
+
throw new Error(`Unsupported source type: ${source.type}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Chunking Strategy
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
// ─── Sentence-Based Chunking ─────────────────────────────────────────────────
|
|
144
|
+
// ~500 tokens per chunk with 50-token overlap for context continuity.
|
|
145
|
+
// Sentence boundaries preserve semantic coherence.
|
|
146
|
+
|
|
147
|
+
interface ChunkConfig {
|
|
148
|
+
maxTokens: number; // Target chunk size (default: 500)
|
|
149
|
+
overlapTokens: number; // Overlap between chunks (default: 50)
|
|
150
|
+
minChunkSize: number; // Minimum chunk size to avoid fragments (default: 100)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function chunkDocument(
|
|
154
|
+
text: string,
|
|
155
|
+
sourceId: string,
|
|
156
|
+
sourceTitle: string,
|
|
157
|
+
config: ChunkConfig = { maxTokens: 500, overlapTokens: 50, minChunkSize: 100 }
|
|
158
|
+
): DocumentChunk[] {
|
|
159
|
+
// Split by sentence boundaries
|
|
160
|
+
const sentences = text.match(/[^.!?]+[.!?]+\s*/g) ?? [text];
|
|
161
|
+
const chunks: DocumentChunk[] = [];
|
|
162
|
+
|
|
163
|
+
let currentChunk = '';
|
|
164
|
+
let chunkStart = 0;
|
|
165
|
+
let offset = 0;
|
|
166
|
+
|
|
167
|
+
for (const sentence of sentences) {
|
|
168
|
+
const estimatedTokens = (currentChunk + sentence).split(/\s+/).length;
|
|
169
|
+
|
|
170
|
+
if (estimatedTokens > config.maxTokens && currentChunk.length > 0) {
|
|
171
|
+
chunks.push({
|
|
172
|
+
id: `${sourceId}-chunk-${chunks.length}`,
|
|
173
|
+
text: currentChunk.trim(),
|
|
174
|
+
sourceId,
|
|
175
|
+
sourceTitle,
|
|
176
|
+
startOffset: chunkStart,
|
|
177
|
+
endOffset: offset,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Overlap: keep last N tokens of current chunk
|
|
181
|
+
const words = currentChunk.split(/\s+/);
|
|
182
|
+
const overlapWords = words.slice(-config.overlapTokens);
|
|
183
|
+
currentChunk = overlapWords.join(' ') + ' ' + sentence;
|
|
184
|
+
chunkStart = offset - overlapWords.join(' ').length;
|
|
185
|
+
} else {
|
|
186
|
+
currentChunk += sentence;
|
|
187
|
+
}
|
|
188
|
+
offset += sentence.length;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Final chunk
|
|
192
|
+
if (currentChunk.trim().split(/\s+/).length >= config.minChunkSize) {
|
|
193
|
+
chunks.push({
|
|
194
|
+
id: `${sourceId}-chunk-${chunks.length}`,
|
|
195
|
+
text: currentChunk.trim(),
|
|
196
|
+
sourceId,
|
|
197
|
+
sourceTitle,
|
|
198
|
+
startOffset: chunkStart,
|
|
199
|
+
endOffset: offset,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return chunks;
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Knowledge Extraction
|
|
208
|
+
|
|
209
|
+
The core data structure that all format generators consume:
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
// ─── Structured Knowledge Representation ─────────────────────────────────────
|
|
213
|
+
// This is the "shared understanding" that fans out to all generators.
|
|
214
|
+
|
|
215
|
+
interface Topic {
|
|
216
|
+
title: string;
|
|
217
|
+
summary: string;
|
|
218
|
+
depth: 'primary' | 'secondary' | 'tertiary';
|
|
219
|
+
sourceRefs: SourceReference[];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
interface Concept {
|
|
223
|
+
term: string;
|
|
224
|
+
definition: string;
|
|
225
|
+
context: string;
|
|
226
|
+
importance: 'critical' | 'important' | 'supplementary';
|
|
227
|
+
sourceRefs: SourceReference[];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
interface Definition {
|
|
231
|
+
term: string;
|
|
232
|
+
definition: string;
|
|
233
|
+
sourceRefs: SourceReference[];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
interface Example {
|
|
237
|
+
description: string;
|
|
238
|
+
relatedConcept: string;
|
|
239
|
+
sourceRefs: SourceReference[];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
interface Statistic {
|
|
243
|
+
value: string;
|
|
244
|
+
context: string;
|
|
245
|
+
sourceRefs: SourceReference[];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface Relationship {
|
|
249
|
+
from: string;
|
|
250
|
+
to: string;
|
|
251
|
+
type: 'causes' | 'contrasts' | 'supports' | 'depends-on' | 'part-of' | 'similar-to';
|
|
252
|
+
description: string;
|
|
253
|
+
sourceRefs: SourceReference[];
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
interface TimelineEvent {
|
|
257
|
+
date: string;
|
|
258
|
+
event: string;
|
|
259
|
+
significance: string;
|
|
260
|
+
sourceRefs: SourceReference[];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
interface SourceReference {
|
|
264
|
+
sourceId: string;
|
|
265
|
+
sourceTitle: string;
|
|
266
|
+
chunkId: string;
|
|
267
|
+
passage: string; // Exact quoted text from source
|
|
268
|
+
pageNumber?: number;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
interface DocumentKnowledge {
|
|
272
|
+
title: string;
|
|
273
|
+
mainTopics: Topic[];
|
|
274
|
+
keyConcepts: Concept[];
|
|
275
|
+
definitions: Definition[];
|
|
276
|
+
examples: Example[];
|
|
277
|
+
statistics: Statistic[];
|
|
278
|
+
relationships: Relationship[];
|
|
279
|
+
timeline?: TimelineEvent[];
|
|
280
|
+
totalSources: number;
|
|
281
|
+
totalChunks: number;
|
|
282
|
+
processingDate: string;
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### AI Extraction Prompt
|
|
287
|
+
|
|
288
|
+
This prompt converts raw chunks into the `DocumentKnowledge` structure. Use with Claude or Gemini.
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
// ─── Knowledge Extraction Prompt ─────────────────────────────────────────────
|
|
292
|
+
|
|
293
|
+
function buildExtractionPrompt(chunks: DocumentChunk[]): string {
|
|
294
|
+
const chunksText = chunks
|
|
295
|
+
.map((c, i) => `[CHUNK ${i + 1} | Source: ${c.sourceTitle} | ID: ${c.id}]\n${c.text}`)
|
|
296
|
+
.join('\n\n---\n\n');
|
|
297
|
+
|
|
298
|
+
return `You are a knowledge extraction system. Analyze the following document chunks and extract structured knowledge.
|
|
299
|
+
|
|
300
|
+
IMPORTANT RULES:
|
|
301
|
+
- Extract ONLY information present in the provided chunks
|
|
302
|
+
- NEVER use your training data to add facts not in the sources
|
|
303
|
+
- Every extracted item MUST include a sourceRef citing the exact chunk and quoted passage
|
|
304
|
+
- If the sources are insufficient for a field, omit it rather than fabricate
|
|
305
|
+
|
|
306
|
+
DOCUMENT CHUNKS:
|
|
307
|
+
${chunksText}
|
|
308
|
+
|
|
309
|
+
Return a JSON object matching this exact structure:
|
|
310
|
+
{
|
|
311
|
+
"title": "Inferred title of the overall content",
|
|
312
|
+
"mainTopics": [
|
|
313
|
+
{
|
|
314
|
+
"title": "Topic name",
|
|
315
|
+
"summary": "2-3 sentence summary",
|
|
316
|
+
"depth": "primary|secondary|tertiary",
|
|
317
|
+
"sourceRefs": [{ "chunkId": "source-chunk-N", "passage": "exact quoted text" }]
|
|
318
|
+
}
|
|
319
|
+
],
|
|
320
|
+
"keyConcepts": [
|
|
321
|
+
{
|
|
322
|
+
"term": "Concept name",
|
|
323
|
+
"definition": "Clear definition",
|
|
324
|
+
"context": "How it's used in this content",
|
|
325
|
+
"importance": "critical|important|supplementary",
|
|
326
|
+
"sourceRefs": [{ "chunkId": "source-chunk-N", "passage": "exact quoted text" }]
|
|
327
|
+
}
|
|
328
|
+
],
|
|
329
|
+
"definitions": [
|
|
330
|
+
{
|
|
331
|
+
"term": "Term",
|
|
332
|
+
"definition": "Definition",
|
|
333
|
+
"sourceRefs": [{ "chunkId": "source-chunk-N", "passage": "exact quoted text" }]
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
"examples": [
|
|
337
|
+
{
|
|
338
|
+
"description": "What the example illustrates",
|
|
339
|
+
"relatedConcept": "Which concept this example supports",
|
|
340
|
+
"sourceRefs": [{ "chunkId": "source-chunk-N", "passage": "exact quoted text" }]
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
"statistics": [
|
|
344
|
+
{
|
|
345
|
+
"value": "The statistic (e.g., '73% of respondents')",
|
|
346
|
+
"context": "What this statistic means",
|
|
347
|
+
"sourceRefs": [{ "chunkId": "source-chunk-N", "passage": "exact quoted text" }]
|
|
348
|
+
}
|
|
349
|
+
],
|
|
350
|
+
"relationships": [
|
|
351
|
+
{
|
|
352
|
+
"from": "Concept A",
|
|
353
|
+
"to": "Concept B",
|
|
354
|
+
"type": "causes|contrasts|supports|depends-on|part-of|similar-to",
|
|
355
|
+
"description": "How they relate",
|
|
356
|
+
"sourceRefs": [{ "chunkId": "source-chunk-N", "passage": "exact quoted text" }]
|
|
357
|
+
}
|
|
358
|
+
],
|
|
359
|
+
"timeline": [
|
|
360
|
+
{
|
|
361
|
+
"date": "Date or time period",
|
|
362
|
+
"event": "What happened",
|
|
363
|
+
"significance": "Why it matters",
|
|
364
|
+
"sourceRefs": [{ "chunkId": "source-chunk-N", "passage": "exact quoted text" }]
|
|
365
|
+
}
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
Return ONLY valid JSON. No markdown fences. Omit empty arrays.`;
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## 2. Format-Specific Generators
|
|
376
|
+
|
|
377
|
+
### A) Podcast Script Generator
|
|
378
|
+
|
|
379
|
+
Transforms `DocumentKnowledge` into a conversational podcast script with two hosts.
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
// ─── Podcast Types ───────────────────────────────────────────────────────────
|
|
383
|
+
|
|
384
|
+
interface PodcastConfig {
|
|
385
|
+
style: 'deep-dive' | 'brief' | 'debate';
|
|
386
|
+
durationMinutes: number; // Target duration: 10, 20, or 45
|
|
387
|
+
hostNames: [string, string]; // Two host names
|
|
388
|
+
tone: 'casual' | 'professional' | 'academic';
|
|
389
|
+
includeIntro: boolean;
|
|
390
|
+
includeOutro: boolean;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
interface PodcastSegment {
|
|
394
|
+
speaker: string;
|
|
395
|
+
text: string;
|
|
396
|
+
direction?: string; // e.g., "(enthusiastic)", "(thoughtful pause)"
|
|
397
|
+
sourceRef?: SourceReference;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
interface PodcastScript {
|
|
401
|
+
title: string;
|
|
402
|
+
estimatedDuration: number; // minutes
|
|
403
|
+
segments: PodcastSegment[];
|
|
404
|
+
showNotes: string;
|
|
405
|
+
chapters: { timestamp: string; title: string }[];
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**AI Prompt Template — Podcast Script:**
|
|
410
|
+
|
|
411
|
+
```
|
|
412
|
+
You are a podcast script writer creating a {style} episode.
|
|
413
|
+
|
|
414
|
+
HOSTS: {hostName1} and {hostName2}
|
|
415
|
+
TARGET DURATION: {durationMinutes} minutes (~{wordCount} words)
|
|
416
|
+
TONE: {tone}
|
|
417
|
+
|
|
418
|
+
SOURCE KNOWLEDGE:
|
|
419
|
+
{JSON.stringify(knowledge, null, 2)}
|
|
420
|
+
|
|
421
|
+
RULES:
|
|
422
|
+
- Create natural, conversational dialogue between the two hosts
|
|
423
|
+
- {hostName1} drives the conversation with questions and transitions
|
|
424
|
+
- {hostName2} provides deeper explanations and examples
|
|
425
|
+
- Include natural speech patterns: "Right, exactly", "That's fascinating", "So what you're saying is..."
|
|
426
|
+
- For "deep-dive": cover every major topic thoroughly with examples
|
|
427
|
+
- For "brief": hit only the top 3-5 key points, keep it punchy
|
|
428
|
+
- For "debate": hosts take opposing perspectives when reasonable, then find common ground
|
|
429
|
+
- EVERY factual claim must trace to a source — include sourceRef for verifiable statements
|
|
430
|
+
- Include direction cues in parentheses: (laughs), (thoughtful pause), (excited)
|
|
431
|
+
- Start with a hook that grabs attention in the first 15 seconds
|
|
432
|
+
- End with a clear takeaway or call to action
|
|
433
|
+
|
|
434
|
+
Return JSON matching the PodcastScript interface.
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
**Cross-reference:** See `content-repurposing-pipeline.md` for turning the script into actual audio using TTS, and `rss-podcast-integration.md` for distribution.
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
### B) Slide Deck Generator
|
|
442
|
+
|
|
443
|
+
```typescript
|
|
444
|
+
// ─── Slide Types ─────────────────────────────────────────────────────────────
|
|
445
|
+
|
|
446
|
+
interface SlideContent {
|
|
447
|
+
title: string;
|
|
448
|
+
subtitle?: string;
|
|
449
|
+
slides: Slide[];
|
|
450
|
+
theme: SlideTheme;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
interface Slide {
|
|
454
|
+
type: 'title' | 'content' | 'comparison' | 'timeline' | 'quote' | 'summary'
|
|
455
|
+
| 'image-prompt' | 'two-column' | 'statistics' | 'diagram';
|
|
456
|
+
title: string;
|
|
457
|
+
bulletPoints?: string[];
|
|
458
|
+
speakerNotes?: string; // What the presenter should say
|
|
459
|
+
imagePrompt?: string; // Prompt for AI image generation (Gemini Imagen)
|
|
460
|
+
sourceRef?: SourceReference; // Which source this slide draws from
|
|
461
|
+
leftColumn?: string[]; // For two-column and comparison slides
|
|
462
|
+
rightColumn?: string[];
|
|
463
|
+
leftLabel?: string;
|
|
464
|
+
rightLabel?: string;
|
|
465
|
+
statistic?: { value: string; label: string; context: string };
|
|
466
|
+
quoteText?: string;
|
|
467
|
+
quoteAttribution?: string;
|
|
468
|
+
timelineEvents?: { date: string; event: string }[];
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
interface SlideTheme {
|
|
472
|
+
primaryColor: string;
|
|
473
|
+
secondaryColor: string;
|
|
474
|
+
fontFamily: string;
|
|
475
|
+
backgroundStyle: 'solid' | 'gradient' | 'image';
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// ─── Slide Defaults ──────────────────────────────────────────────────────────
|
|
479
|
+
|
|
480
|
+
const DEFAULT_SLIDE_THEME: SlideTheme = {
|
|
481
|
+
primaryColor: '#1a1a2e',
|
|
482
|
+
secondaryColor: '#e94560',
|
|
483
|
+
fontFamily: 'Inter, system-ui, sans-serif',
|
|
484
|
+
backgroundStyle: 'gradient',
|
|
485
|
+
};
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
**AI Prompt Template — Slide Deck:**
|
|
489
|
+
|
|
490
|
+
```
|
|
491
|
+
You are a presentation designer. Create a slide deck from the following knowledge base.
|
|
492
|
+
|
|
493
|
+
TARGET: {slideCount} slides for a {durationMinutes}-minute presentation
|
|
494
|
+
AUDIENCE: {audience}
|
|
495
|
+
|
|
496
|
+
SOURCE KNOWLEDGE:
|
|
497
|
+
{JSON.stringify(knowledge, null, 2)}
|
|
498
|
+
|
|
499
|
+
SLIDE STRUCTURE GUIDELINES:
|
|
500
|
+
- Slide 1: Title slide with compelling subtitle
|
|
501
|
+
- Slide 2: Overview / agenda (3-5 main points)
|
|
502
|
+
- Slides 3-{N-2}: Content slides — one key idea per slide
|
|
503
|
+
- Use "comparison" type when contrasting two things
|
|
504
|
+
- Use "timeline" type for chronological content
|
|
505
|
+
- Use "quote" type for powerful source quotes
|
|
506
|
+
- Use "statistics" type for data-driven points
|
|
507
|
+
- Use "two-column" for pros/cons, before/after, etc.
|
|
508
|
+
- Slide {N-1}: Key takeaways (3-5 bullet points)
|
|
509
|
+
- Slide {N}: Call to action or closing thought
|
|
510
|
+
|
|
511
|
+
RULES:
|
|
512
|
+
- Maximum 5 bullet points per slide (audience reads, not listens, if overloaded)
|
|
513
|
+
- Each bullet point: 8-12 words max
|
|
514
|
+
- Speaker notes: 2-4 sentences of what to SAY (not what's on the slide)
|
|
515
|
+
- Include imagePrompt for slides that benefit from visuals
|
|
516
|
+
- Use descriptive prompts suitable for Gemini Imagen: "Professional photograph of..."
|
|
517
|
+
- NEVER reference copyrighted characters or real people
|
|
518
|
+
- Every content slide must have a sourceRef tracing back to source material
|
|
519
|
+
- Slides should tell a STORY: setup → conflict/challenge → resolution → action
|
|
520
|
+
|
|
521
|
+
Return JSON matching the SlideContent interface.
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
**HTML Export (self-contained, single file):**
|
|
525
|
+
|
|
526
|
+
```typescript
|
|
527
|
+
// ─── Slide Deck → Self-Contained HTML ────────────────────────────────────────
|
|
528
|
+
|
|
529
|
+
function slidesToHTML(deck: SlideContent): string {
|
|
530
|
+
const slideHTML = deck.slides.map((slide, index) => {
|
|
531
|
+
let content = '';
|
|
532
|
+
|
|
533
|
+
switch (slide.type) {
|
|
534
|
+
case 'title':
|
|
535
|
+
content = `
|
|
536
|
+
<div class="slide slide-title">
|
|
537
|
+
<h1>${escapeHtml(deck.title)}</h1>
|
|
538
|
+
${deck.subtitle ? `<p class="subtitle">${escapeHtml(deck.subtitle)}</p>` : ''}
|
|
539
|
+
</div>`;
|
|
540
|
+
break;
|
|
541
|
+
|
|
542
|
+
case 'content':
|
|
543
|
+
content = `
|
|
544
|
+
<div class="slide slide-content">
|
|
545
|
+
<h2>${escapeHtml(slide.title)}</h2>
|
|
546
|
+
<ul>${(slide.bulletPoints ?? []).map(bp =>
|
|
547
|
+
`<li>${escapeHtml(bp)}</li>`
|
|
548
|
+
).join('')}</ul>
|
|
549
|
+
</div>`;
|
|
550
|
+
break;
|
|
551
|
+
|
|
552
|
+
case 'comparison':
|
|
553
|
+
content = `
|
|
554
|
+
<div class="slide slide-comparison">
|
|
555
|
+
<h2>${escapeHtml(slide.title)}</h2>
|
|
556
|
+
<div class="columns">
|
|
557
|
+
<div class="column">
|
|
558
|
+
<h3>${escapeHtml(slide.leftLabel ?? 'Option A')}</h3>
|
|
559
|
+
<ul>${(slide.leftColumn ?? []).map(item =>
|
|
560
|
+
`<li>${escapeHtml(item)}</li>`
|
|
561
|
+
).join('')}</ul>
|
|
562
|
+
</div>
|
|
563
|
+
<div class="column">
|
|
564
|
+
<h3>${escapeHtml(slide.rightLabel ?? 'Option B')}</h3>
|
|
565
|
+
<ul>${(slide.rightColumn ?? []).map(item =>
|
|
566
|
+
`<li>${escapeHtml(item)}</li>`
|
|
567
|
+
).join('')}</ul>
|
|
568
|
+
</div>
|
|
569
|
+
</div>
|
|
570
|
+
</div>`;
|
|
571
|
+
break;
|
|
572
|
+
|
|
573
|
+
case 'quote':
|
|
574
|
+
content = `
|
|
575
|
+
<div class="slide slide-quote">
|
|
576
|
+
<blockquote>
|
|
577
|
+
<p>"${escapeHtml(slide.quoteText ?? '')}"</p>
|
|
578
|
+
${slide.quoteAttribution
|
|
579
|
+
? `<cite>— ${escapeHtml(slide.quoteAttribution)}</cite>`
|
|
580
|
+
: ''}
|
|
581
|
+
</blockquote>
|
|
582
|
+
</div>`;
|
|
583
|
+
break;
|
|
584
|
+
|
|
585
|
+
case 'statistics':
|
|
586
|
+
content = `
|
|
587
|
+
<div class="slide slide-statistics">
|
|
588
|
+
<h2>${escapeHtml(slide.title)}</h2>
|
|
589
|
+
${slide.statistic ? `
|
|
590
|
+
<div class="stat-block">
|
|
591
|
+
<span class="stat-value">${escapeHtml(slide.statistic.value)}</span>
|
|
592
|
+
<span class="stat-label">${escapeHtml(slide.statistic.label)}</span>
|
|
593
|
+
<p class="stat-context">${escapeHtml(slide.statistic.context)}</p>
|
|
594
|
+
</div>` : ''}
|
|
595
|
+
</div>`;
|
|
596
|
+
break;
|
|
597
|
+
|
|
598
|
+
case 'timeline':
|
|
599
|
+
content = `
|
|
600
|
+
<div class="slide slide-timeline">
|
|
601
|
+
<h2>${escapeHtml(slide.title)}</h2>
|
|
602
|
+
<div class="timeline">
|
|
603
|
+
${(slide.timelineEvents ?? []).map(evt => `
|
|
604
|
+
<div class="timeline-event">
|
|
605
|
+
<span class="timeline-date">${escapeHtml(evt.date)}</span>
|
|
606
|
+
<span class="timeline-desc">${escapeHtml(evt.event)}</span>
|
|
607
|
+
</div>
|
|
608
|
+
`).join('')}
|
|
609
|
+
</div>
|
|
610
|
+
</div>`;
|
|
611
|
+
break;
|
|
612
|
+
|
|
613
|
+
case 'summary':
|
|
614
|
+
content = `
|
|
615
|
+
<div class="slide slide-summary">
|
|
616
|
+
<h2>${escapeHtml(slide.title)}</h2>
|
|
617
|
+
<ul class="summary-list">${(slide.bulletPoints ?? []).map(bp =>
|
|
618
|
+
`<li>${escapeHtml(bp)}</li>`
|
|
619
|
+
).join('')}</ul>
|
|
620
|
+
</div>`;
|
|
621
|
+
break;
|
|
622
|
+
|
|
623
|
+
default:
|
|
624
|
+
content = `
|
|
625
|
+
<div class="slide slide-content">
|
|
626
|
+
<h2>${escapeHtml(slide.title)}</h2>
|
|
627
|
+
<ul>${(slide.bulletPoints ?? []).map(bp =>
|
|
628
|
+
`<li>${escapeHtml(bp)}</li>`
|
|
629
|
+
).join('')}</ul>
|
|
630
|
+
</div>`;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
return `<section data-index="${index}">${content}</section>`;
|
|
634
|
+
}).join('\n');
|
|
635
|
+
|
|
636
|
+
return `<!DOCTYPE html>
|
|
637
|
+
<html lang="en">
|
|
638
|
+
<head>
|
|
639
|
+
<meta charset="UTF-8">
|
|
640
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
641
|
+
<title>${escapeHtml(deck.title)}</title>
|
|
642
|
+
<style>
|
|
643
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
644
|
+
body { font-family: ${deck.theme.fontFamily}; background: #000; overflow: hidden; }
|
|
645
|
+
section { display: none; width: 100vw; height: 100vh; padding: 60px 80px;
|
|
646
|
+
background: linear-gradient(135deg, ${deck.theme.primaryColor}, #16213e);
|
|
647
|
+
color: #fff; }
|
|
648
|
+
section.active { display: flex; flex-direction: column; justify-content: center; }
|
|
649
|
+
h1 { font-size: 3.5rem; margin-bottom: 0.5em; }
|
|
650
|
+
h2 { font-size: 2.5rem; margin-bottom: 1em; color: ${deck.theme.secondaryColor}; }
|
|
651
|
+
h3 { font-size: 1.5rem; margin-bottom: 0.5em; color: ${deck.theme.secondaryColor}; }
|
|
652
|
+
ul { list-style: none; padding-left: 0; }
|
|
653
|
+
li { font-size: 1.5rem; margin-bottom: 0.6em; padding-left: 1.5em;
|
|
654
|
+
position: relative; line-height: 1.4; }
|
|
655
|
+
li::before { content: "\\25B6"; position: absolute; left: 0;
|
|
656
|
+
color: ${deck.theme.secondaryColor}; font-size: 0.8em; }
|
|
657
|
+
.subtitle { font-size: 1.5rem; opacity: 0.8; }
|
|
658
|
+
.columns { display: flex; gap: 60px; }
|
|
659
|
+
.column { flex: 1; }
|
|
660
|
+
blockquote { font-size: 2rem; font-style: italic; line-height: 1.6;
|
|
661
|
+
border-left: 4px solid ${deck.theme.secondaryColor}; padding-left: 30px; }
|
|
662
|
+
cite { display: block; margin-top: 1em; font-size: 1.2rem; opacity: 0.7; }
|
|
663
|
+
.stat-block { text-align: center; margin-top: 2em; }
|
|
664
|
+
.stat-value { font-size: 5rem; font-weight: bold; color: ${deck.theme.secondaryColor}; display: block; }
|
|
665
|
+
.stat-label { font-size: 1.5rem; display: block; margin-top: 0.3em; }
|
|
666
|
+
.stat-context { font-size: 1.1rem; opacity: 0.7; margin-top: 1em; }
|
|
667
|
+
.timeline { position: relative; padding-left: 30px;
|
|
668
|
+
border-left: 3px solid ${deck.theme.secondaryColor}; }
|
|
669
|
+
.timeline-event { margin-bottom: 1.5em; }
|
|
670
|
+
.timeline-date { font-weight: bold; color: ${deck.theme.secondaryColor};
|
|
671
|
+
font-size: 1.2rem; display: block; }
|
|
672
|
+
.timeline-desc { font-size: 1.3rem; }
|
|
673
|
+
.nav-hint { position: fixed; bottom: 20px; right: 30px; font-size: 0.9rem;
|
|
674
|
+
opacity: 0.4; color: #fff; }
|
|
675
|
+
.slide-counter { position: fixed; bottom: 20px; left: 30px; font-size: 0.9rem;
|
|
676
|
+
opacity: 0.4; color: #fff; }
|
|
677
|
+
</style>
|
|
678
|
+
</head>
|
|
679
|
+
<body>
|
|
680
|
+
${slideHTML}
|
|
681
|
+
<div class="nav-hint">Arrow keys or click to navigate</div>
|
|
682
|
+
<div class="slide-counter" id="counter"></div>
|
|
683
|
+
<script>
|
|
684
|
+
const sections = document.querySelectorAll('section');
|
|
685
|
+
let current = 0;
|
|
686
|
+
function show(n) {
|
|
687
|
+
sections.forEach(s => s.classList.remove('active'));
|
|
688
|
+
current = Math.max(0, Math.min(n, sections.length - 1));
|
|
689
|
+
sections[current].classList.add('active');
|
|
690
|
+
document.getElementById('counter').textContent = (current + 1) + ' / ' + sections.length;
|
|
691
|
+
}
|
|
692
|
+
show(0);
|
|
693
|
+
document.addEventListener('keydown', e => {
|
|
694
|
+
if (e.key === 'ArrowRight' || e.key === ' ') show(current + 1);
|
|
695
|
+
if (e.key === 'ArrowLeft') show(current - 1);
|
|
696
|
+
if (e.key === 'Home') show(0);
|
|
697
|
+
if (e.key === 'End') show(sections.length - 1);
|
|
698
|
+
});
|
|
699
|
+
document.addEventListener('click', e => {
|
|
700
|
+
if (e.clientX > window.innerWidth / 2) show(current + 1);
|
|
701
|
+
else show(current - 1);
|
|
702
|
+
});
|
|
703
|
+
</script>
|
|
704
|
+
</body>
|
|
705
|
+
</html>`;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
function escapeHtml(str: string): string {
|
|
709
|
+
return str.replace(/&/g, '&').replace(/</g, '<')
|
|
710
|
+
.replace(/>/g, '>').replace(/"/g, '"');
|
|
711
|
+
}
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
---
|
|
715
|
+
|
|
716
|
+
### C) Flashcard Generator
|
|
717
|
+
|
|
718
|
+
```typescript
|
|
719
|
+
// ─── Flashcard Types ─────────────────────────────────────────────────────────
|
|
720
|
+
|
|
721
|
+
interface Flashcard {
|
|
722
|
+
front: string; // Question or concept
|
|
723
|
+
back: string; // Answer or definition
|
|
724
|
+
difficulty: 'easy' | 'medium' | 'hard';
|
|
725
|
+
tags: string[];
|
|
726
|
+
source: string; // Which document/page
|
|
727
|
+
sourceRef: SourceReference;
|
|
728
|
+
// Spaced repetition metadata
|
|
729
|
+
sr: {
|
|
730
|
+
interval: number; // Days until next review (initial: 1)
|
|
731
|
+
easeFactor: number; // SM-2 ease factor (initial: 2.5)
|
|
732
|
+
repetitions: number; // Number of successful reviews (initial: 0)
|
|
733
|
+
nextReview: string; // ISO date string
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// ─── Generation from DocumentKnowledge ───────────────────────────────────────
|
|
738
|
+
|
|
739
|
+
function generateFlashcardsFromKnowledge(knowledge: DocumentKnowledge): Flashcard[] {
|
|
740
|
+
const cards: Flashcard[] = [];
|
|
741
|
+
const now = new Date().toISOString();
|
|
742
|
+
|
|
743
|
+
// 1. Definition cards (easiest to generate, highest value)
|
|
744
|
+
for (const def of knowledge.definitions) {
|
|
745
|
+
cards.push({
|
|
746
|
+
front: `Define: ${def.term}`,
|
|
747
|
+
back: def.definition,
|
|
748
|
+
difficulty: 'easy',
|
|
749
|
+
tags: ['definition', ...extractTopicTags(def.term, knowledge)],
|
|
750
|
+
source: def.sourceRefs[0]?.sourceTitle ?? 'Unknown',
|
|
751
|
+
sourceRef: def.sourceRefs[0],
|
|
752
|
+
sr: { interval: 1, easeFactor: 2.5, repetitions: 0, nextReview: now },
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// 2. Concept cards (test understanding, not just recall)
|
|
757
|
+
for (const concept of knowledge.keyConcepts) {
|
|
758
|
+
cards.push({
|
|
759
|
+
front: `What is ${concept.term} and why does it matter?`,
|
|
760
|
+
back: `${concept.definition}\n\nContext: ${concept.context}`,
|
|
761
|
+
difficulty: concept.importance === 'critical' ? 'hard' : 'medium',
|
|
762
|
+
tags: ['concept', concept.importance],
|
|
763
|
+
source: concept.sourceRefs[0]?.sourceTitle ?? 'Unknown',
|
|
764
|
+
sourceRef: concept.sourceRefs[0],
|
|
765
|
+
sr: { interval: 1, easeFactor: 2.5, repetitions: 0, nextReview: now },
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// 3. Relationship cards (connect ideas)
|
|
770
|
+
for (const rel of knowledge.relationships) {
|
|
771
|
+
cards.push({
|
|
772
|
+
front: `How does "${rel.from}" relate to "${rel.to}"?`,
|
|
773
|
+
back: `Relationship type: ${rel.type}\n\n${rel.description}`,
|
|
774
|
+
difficulty: 'hard',
|
|
775
|
+
tags: ['relationship', rel.type],
|
|
776
|
+
source: rel.sourceRefs[0]?.sourceTitle ?? 'Unknown',
|
|
777
|
+
sourceRef: rel.sourceRefs[0],
|
|
778
|
+
sr: { interval: 1, easeFactor: 2.5, repetitions: 0, nextReview: now },
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// 4. Example cards (apply knowledge)
|
|
783
|
+
for (const example of knowledge.examples) {
|
|
784
|
+
cards.push({
|
|
785
|
+
front: `Give an example of "${example.relatedConcept}" in practice.`,
|
|
786
|
+
back: example.description,
|
|
787
|
+
difficulty: 'medium',
|
|
788
|
+
tags: ['example', example.relatedConcept],
|
|
789
|
+
source: example.sourceRefs[0]?.sourceTitle ?? 'Unknown',
|
|
790
|
+
sourceRef: example.sourceRefs[0],
|
|
791
|
+
sr: { interval: 1, easeFactor: 2.5, repetitions: 0, nextReview: now },
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// 5. Statistics cards (recall data points)
|
|
796
|
+
for (const stat of knowledge.statistics) {
|
|
797
|
+
cards.push({
|
|
798
|
+
front: stat.context,
|
|
799
|
+
back: stat.value,
|
|
800
|
+
difficulty: 'medium',
|
|
801
|
+
tags: ['statistic'],
|
|
802
|
+
source: stat.sourceRefs[0]?.sourceTitle ?? 'Unknown',
|
|
803
|
+
sourceRef: stat.sourceRefs[0],
|
|
804
|
+
sr: { interval: 1, easeFactor: 2.5, repetitions: 0, nextReview: now },
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
return cards;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
function extractTopicTags(term: string, knowledge: DocumentKnowledge): string[] {
|
|
812
|
+
return knowledge.mainTopics
|
|
813
|
+
.filter(t => t.title.toLowerCase().includes(term.toLowerCase())
|
|
814
|
+
|| t.summary.toLowerCase().includes(term.toLowerCase()))
|
|
815
|
+
.map(t => t.title.toLowerCase().replace(/\s+/g, '-'));
|
|
816
|
+
}
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
**Export Formats:**
|
|
820
|
+
|
|
821
|
+
```typescript
|
|
822
|
+
// ─── Flashcard Export ────────────────────────────────────────────────────────
|
|
823
|
+
|
|
824
|
+
// JSON export (universal)
|
|
825
|
+
function exportFlashcardsJSON(cards: Flashcard[]): string {
|
|
826
|
+
return JSON.stringify(cards, null, 2);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
// Anki-compatible CSV (importable via File > Import)
|
|
830
|
+
// Format: front<tab>back<tab>tags
|
|
831
|
+
function exportFlashcardsAnkiCSV(cards: Flashcard[]): string {
|
|
832
|
+
const header = '#separator:tab\n#html:false\n#tags column:3\n';
|
|
833
|
+
const rows = cards.map(c =>
|
|
834
|
+
`${c.front}\t${c.back.replace(/\n/g, '<br>')}\t${c.tags.join(' ')}`
|
|
835
|
+
);
|
|
836
|
+
return header + rows.join('\n');
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
// Markdown export (human-readable study format)
|
|
840
|
+
function exportFlashcardsMarkdown(cards: Flashcard[]): string {
|
|
841
|
+
const grouped = groupBy(cards, c => c.difficulty);
|
|
842
|
+
let md = '# Flashcards\n\n';
|
|
843
|
+
|
|
844
|
+
for (const [difficulty, group] of Object.entries(grouped)) {
|
|
845
|
+
md += `## ${difficulty.charAt(0).toUpperCase() + difficulty.slice(1)}\n\n`;
|
|
846
|
+
for (const card of group as Flashcard[]) {
|
|
847
|
+
md += `**Q:** ${card.front}\n\n`;
|
|
848
|
+
md += `**A:** ${card.back}\n\n`;
|
|
849
|
+
md += `*Source: ${card.source}*\n\n---\n\n`;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return md;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
function groupBy<T>(arr: T[], fn: (item: T) => string): Record<string, T[]> {
|
|
857
|
+
return arr.reduce((acc, item) => {
|
|
858
|
+
const key = fn(item);
|
|
859
|
+
(acc[key] ??= []).push(item);
|
|
860
|
+
return acc;
|
|
861
|
+
}, {} as Record<string, T[]>);
|
|
862
|
+
}
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
---
|
|
866
|
+
|
|
867
|
+
### D) Quiz Generator
|
|
868
|
+
|
|
869
|
+
```typescript
|
|
870
|
+
// ─── Quiz Types ──────────────────────────────────────────────────────────────
|
|
871
|
+
|
|
872
|
+
interface QuizQuestion {
|
|
873
|
+
type: 'multiple-choice' | 'true-false' | 'short-answer' | 'fill-blank';
|
|
874
|
+
question: string;
|
|
875
|
+
options?: string[]; // For multiple-choice (4 options, A-D)
|
|
876
|
+
correctAnswer: string;
|
|
877
|
+
explanation: string; // Why this is the correct answer
|
|
878
|
+
difficulty: 'easy' | 'medium' | 'hard';
|
|
879
|
+
sourceReference: string; // Cited source passage for verification
|
|
880
|
+
topic: string; // Which topic this tests
|
|
881
|
+
bloomsLevel: 'remember' | 'understand' | 'apply' | 'analyze' | 'evaluate' | 'create';
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
interface Quiz {
|
|
885
|
+
title: string;
|
|
886
|
+
description: string;
|
|
887
|
+
questions: QuizQuestion[];
|
|
888
|
+
passingScore: number; // Percentage (e.g., 70)
|
|
889
|
+
timeLimit?: number; // Minutes
|
|
890
|
+
generatedFrom: string[]; // Source titles
|
|
891
|
+
}
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
**AI Prompt Template — Quiz Generation:**
|
|
895
|
+
|
|
896
|
+
```
|
|
897
|
+
You are a quiz generator creating assessment questions from source material.
|
|
898
|
+
|
|
899
|
+
TARGET: {questionCount} questions across multiple difficulty levels
|
|
900
|
+
DISTRIBUTION:
|
|
901
|
+
- 30% easy (remember/understand — definitions, basic facts)
|
|
902
|
+
- 40% medium (apply/analyze — use concepts in scenarios)
|
|
903
|
+
- 30% hard (evaluate/create — judge, compare, synthesize)
|
|
904
|
+
|
|
905
|
+
QUESTION TYPES (mix all four):
|
|
906
|
+
- multiple-choice: 4 options (A-D), exactly 1 correct
|
|
907
|
+
- true-false: statement that is clearly true or false
|
|
908
|
+
- short-answer: requires 1-3 sentence response
|
|
909
|
+
- fill-blank: sentence with a key term removed
|
|
910
|
+
|
|
911
|
+
SOURCE KNOWLEDGE:
|
|
912
|
+
{JSON.stringify(knowledge, null, 2)}
|
|
913
|
+
|
|
914
|
+
CRITICAL RULES FOR MULTIPLE-CHOICE DISTRACTORS:
|
|
915
|
+
1. All wrong answers must be PLAUSIBLE — they should sound reasonable to someone
|
|
916
|
+
who has not studied the material carefully
|
|
917
|
+
2. Avoid obviously wrong answers (e.g., joke answers, completely unrelated terms)
|
|
918
|
+
3. Use common misconceptions as distractors when possible
|
|
919
|
+
4. Distractors should be similar in length and structure to the correct answer
|
|
920
|
+
5. Avoid "all of the above" or "none of the above"
|
|
921
|
+
6. Randomize correct answer position (not always B or C)
|
|
922
|
+
|
|
923
|
+
CRITICAL RULES FOR ALL QUESTIONS:
|
|
924
|
+
1. Every question must be answerable from the source material alone
|
|
925
|
+
2. Include the exact source passage in sourceReference
|
|
926
|
+
3. The explanation must cite the source and explain WHY the answer is correct
|
|
927
|
+
4. For true-false: make false statements subtle (change one key detail, not everything)
|
|
928
|
+
5. For fill-blank: remove a SPECIFIC TERM, not a generic word
|
|
929
|
+
6. Tag each question with its Bloom's taxonomy level
|
|
930
|
+
7. NEVER test on information not present in the sources
|
|
931
|
+
|
|
932
|
+
Return JSON matching the Quiz interface.
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
**Distractor Generation Strategy:**
|
|
936
|
+
|
|
937
|
+
```typescript
|
|
938
|
+
// ─── Distractor Generation Patterns ──────────────────────────────────────────
|
|
939
|
+
// These patterns produce plausible wrong answers for multiple-choice questions.
|
|
940
|
+
|
|
941
|
+
type DistractorStrategy =
|
|
942
|
+
| 'related-concept' // A real concept from the sources, but not the answer
|
|
943
|
+
| 'partial-truth' // Correct premise + wrong conclusion
|
|
944
|
+
| 'common-misconception'// What someone might guess without studying
|
|
945
|
+
| 'similar-term' // A term that sounds like the right answer
|
|
946
|
+
| 'opposite' // The inverse of the correct answer
|
|
947
|
+
| 'overgeneralization'; // Takes the correct answer too far
|
|
948
|
+
|
|
949
|
+
// Example: If the correct answer is "Photosynthesis converts CO2 and water into glucose"
|
|
950
|
+
// Distractors:
|
|
951
|
+
// related-concept: "Cellular respiration converts glucose into ATP"
|
|
952
|
+
// partial-truth: "Photosynthesis converts oxygen and water into glucose"
|
|
953
|
+
// common-misconception: "Photosynthesis converts sunlight directly into food"
|
|
954
|
+
// overgeneralization: "Photosynthesis converts all gases into glucose"
|
|
955
|
+
|
|
956
|
+
// The AI prompt above handles this, but for programmatic generation:
|
|
957
|
+
function buildDistractorPrompt(
|
|
958
|
+
correctAnswer: string,
|
|
959
|
+
knowledge: DocumentKnowledge,
|
|
960
|
+
strategy: DistractorStrategy
|
|
961
|
+
): string {
|
|
962
|
+
return `Generate a plausible but INCORRECT answer using the "${strategy}" strategy.
|
|
963
|
+
Correct answer: "${correctAnswer}"
|
|
964
|
+
Available concepts: ${knowledge.keyConcepts.map(c => c.term).join(', ')}
|
|
965
|
+
The distractor must sound reasonable and be similar in length to the correct answer.
|
|
966
|
+
Return ONLY the distractor text, nothing else.`;
|
|
967
|
+
}
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
---
|
|
971
|
+
|
|
972
|
+
### E) Summary Generator
|
|
973
|
+
|
|
974
|
+
Three lengths for different channels:
|
|
975
|
+
|
|
976
|
+
```typescript
|
|
977
|
+
// ─── Summary Types ───────────────────────────────────────────────────────────
|
|
978
|
+
|
|
979
|
+
type SummaryLength = 'short' | 'medium' | 'long';
|
|
980
|
+
|
|
981
|
+
interface SummaryConfig {
|
|
982
|
+
length: SummaryLength;
|
|
983
|
+
audience: 'general' | 'technical' | 'executive' | 'ministry';
|
|
984
|
+
includeSourceCitations: boolean;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
// ─── Summary Length Specifications ───────────────────────────────────────────
|
|
988
|
+
|
|
989
|
+
const SUMMARY_SPECS: Record<SummaryLength, { words: string; useCase: string; prompt: string }> = {
|
|
990
|
+
short: {
|
|
991
|
+
words: '25-50',
|
|
992
|
+
useCase: 'Social media post, executive one-liner, email subject preview',
|
|
993
|
+
prompt: `Write a 1-2 sentence summary (25-50 words) that captures the single most important
|
|
994
|
+
takeaway. This will be used for social media or as an executive brief. Be punchy and specific.
|
|
995
|
+
Do NOT start with "This document..." — start with the insight itself.`,
|
|
996
|
+
},
|
|
997
|
+
medium: {
|
|
998
|
+
words: '100-200',
|
|
999
|
+
useCase: 'Newsletter paragraph, email body, meeting notes',
|
|
1000
|
+
prompt: `Write a 1-paragraph summary (100-200 words) covering the main argument, key
|
|
1001
|
+
supporting points, and conclusion. This will be used in newsletters or email communications.
|
|
1002
|
+
Use clear, professional language. Cite specific findings or data points from the sources.`,
|
|
1003
|
+
},
|
|
1004
|
+
long: {
|
|
1005
|
+
words: '500-1000',
|
|
1006
|
+
useCase: 'Blog post, study guide, comprehensive briefing',
|
|
1007
|
+
prompt: `Write a full-page summary (500-1000 words) organized with headers and sections.
|
|
1008
|
+
Include:
|
|
1009
|
+
- An introduction that frames the topic
|
|
1010
|
+
- Key findings or arguments (3-5 sections with headers)
|
|
1011
|
+
- Supporting evidence and examples from the sources
|
|
1012
|
+
- A conclusion with implications or action items
|
|
1013
|
+
- Inline citations referencing specific source passages
|
|
1014
|
+
|
|
1015
|
+
Format as Markdown with ## headers. This will serve as a standalone blog post or study guide.`,
|
|
1016
|
+
},
|
|
1017
|
+
};
|
|
1018
|
+
```
|
|
1019
|
+
|
|
1020
|
+
**AI Prompt Template — Summary:**
|
|
1021
|
+
|
|
1022
|
+
```
|
|
1023
|
+
You are a content summarizer. Generate a {length} summary of the following knowledge base.
|
|
1024
|
+
|
|
1025
|
+
AUDIENCE: {audience}
|
|
1026
|
+
LENGTH SPEC: {SUMMARY_SPECS[length].words} words
|
|
1027
|
+
USE CASE: {SUMMARY_SPECS[length].useCase}
|
|
1028
|
+
|
|
1029
|
+
{SUMMARY_SPECS[length].prompt}
|
|
1030
|
+
|
|
1031
|
+
SOURCE KNOWLEDGE:
|
|
1032
|
+
{JSON.stringify(knowledge, null, 2)}
|
|
1033
|
+
|
|
1034
|
+
RULES:
|
|
1035
|
+
- Use ONLY information from the provided sources
|
|
1036
|
+
- {includeSourceCitations ? 'Include inline citations in [Source: title] format' : 'No citations needed'}
|
|
1037
|
+
- Match the tone to the audience:
|
|
1038
|
+
- general: clear, jargon-free, engaging
|
|
1039
|
+
- technical: precise, domain-specific terms OK
|
|
1040
|
+
- executive: bottom-line-up-front, action-oriented
|
|
1041
|
+
- ministry: warm, scripture-grounded, pastoral
|
|
1042
|
+
|
|
1043
|
+
Return the summary as plain text (short/medium) or Markdown (long).
|
|
1044
|
+
```
|
|
1045
|
+
|
|
1046
|
+
---
|
|
1047
|
+
|
|
1048
|
+
### F) FAQ Generator
|
|
1049
|
+
|
|
1050
|
+
```typescript
|
|
1051
|
+
// ─── FAQ Types ───────────────────────────────────────────────────────────────
|
|
1052
|
+
|
|
1053
|
+
interface FAQ {
|
|
1054
|
+
question: string;
|
|
1055
|
+
answer: string;
|
|
1056
|
+
category: string; // Topic grouping
|
|
1057
|
+
sourceRef: SourceReference;
|
|
1058
|
+
confidence: 'high' | 'medium'; // How directly the source addresses this
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
interface FAQCollection {
|
|
1062
|
+
title: string;
|
|
1063
|
+
description: string;
|
|
1064
|
+
faqs: FAQ[];
|
|
1065
|
+
generatedFrom: string[];
|
|
1066
|
+
}
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
**AI Prompt Template — FAQ:**
|
|
1070
|
+
|
|
1071
|
+
```
|
|
1072
|
+
You are generating a FAQ document from source material.
|
|
1073
|
+
|
|
1074
|
+
SOURCE KNOWLEDGE:
|
|
1075
|
+
{JSON.stringify(knowledge, null, 2)}
|
|
1076
|
+
|
|
1077
|
+
Generate 10-20 frequently asked questions that a reader would likely have after
|
|
1078
|
+
encountering this material. Organize by topic category.
|
|
1079
|
+
|
|
1080
|
+
QUESTION TYPES TO INCLUDE:
|
|
1081
|
+
1. "What is...?" — Basic understanding questions (from definitions)
|
|
1082
|
+
2. "How does...?" — Process/mechanism questions (from relationships)
|
|
1083
|
+
3. "Why is...important?" — Significance questions (from key concepts)
|
|
1084
|
+
4. "What's the difference between...?" — Comparison questions (from relationships)
|
|
1085
|
+
5. "Can you give an example of...?" — Application questions (from examples)
|
|
1086
|
+
6. "What does the data show about...?" — Evidence questions (from statistics)
|
|
1087
|
+
|
|
1088
|
+
RULES:
|
|
1089
|
+
- Every answer must be grounded in the source material
|
|
1090
|
+
- Include the exact source passage in the sourceRef
|
|
1091
|
+
- If the sources don't fully address a likely question, set confidence to "medium"
|
|
1092
|
+
and note "Based on available sources..." in the answer
|
|
1093
|
+
- Never fabricate answers — if the sources don't cover it, skip the question
|
|
1094
|
+
- Answers should be concise (2-5 sentences) but complete
|
|
1095
|
+
- Group FAQs by category matching the main topics
|
|
1096
|
+
|
|
1097
|
+
Return JSON matching the FAQCollection interface.
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
---
|
|
1101
|
+
|
|
1102
|
+
### G) Study Guide Generator
|
|
1103
|
+
|
|
1104
|
+
```typescript
|
|
1105
|
+
// ─── Study Guide Types ───────────────────────────────────────────────────────
|
|
1106
|
+
|
|
1107
|
+
interface StudyGuideSection {
|
|
1108
|
+
title: string;
|
|
1109
|
+
learningObjectives: string[];
|
|
1110
|
+
keyTerms: { term: string; definition: string }[];
|
|
1111
|
+
conceptSummary: string;
|
|
1112
|
+
practiceQuestions: string[];
|
|
1113
|
+
reflectionPrompts: string[]; // Open-ended thinking questions
|
|
1114
|
+
sourceRefs: SourceReference[];
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
interface StudyGuide {
|
|
1118
|
+
title: string;
|
|
1119
|
+
overview: string;
|
|
1120
|
+
sections: StudyGuideSection[];
|
|
1121
|
+
reviewChecklist: string[]; // "I can explain...", "I understand..."
|
|
1122
|
+
suggestedReadings: string[]; // From source references
|
|
1123
|
+
}
|
|
1124
|
+
```
|
|
1125
|
+
|
|
1126
|
+
**AI Prompt Template — Study Guide:**
|
|
1127
|
+
|
|
1128
|
+
```
|
|
1129
|
+
You are creating a study guide from source material for active learning.
|
|
1130
|
+
|
|
1131
|
+
SOURCE KNOWLEDGE:
|
|
1132
|
+
{JSON.stringify(knowledge, null, 2)}
|
|
1133
|
+
|
|
1134
|
+
Create a structured study guide with these components per section:
|
|
1135
|
+
1. Learning objectives (what the student will be able to do after studying)
|
|
1136
|
+
2. Key terms with definitions
|
|
1137
|
+
3. Concept summary (2-3 paragraphs)
|
|
1138
|
+
4. Practice questions (factual recall)
|
|
1139
|
+
5. Reflection prompts (higher-order thinking — "How would you apply..." or "Compare...")
|
|
1140
|
+
|
|
1141
|
+
End with a self-assessment checklist: "After studying, I can..."
|
|
1142
|
+
- Use "I can explain..." for understanding
|
|
1143
|
+
- Use "I can compare..." for analysis
|
|
1144
|
+
- Use "I can apply..." for application
|
|
1145
|
+
|
|
1146
|
+
RULES:
|
|
1147
|
+
- Every fact must trace to source material
|
|
1148
|
+
- Learning objectives should use Bloom's taxonomy verbs
|
|
1149
|
+
- Reflection prompts should encourage connections between topics
|
|
1150
|
+
- Keep language accessible — define jargon on first use
|
|
1151
|
+
|
|
1152
|
+
Return JSON matching the StudyGuide interface.
|
|
1153
|
+
```
|
|
1154
|
+
|
|
1155
|
+
---
|
|
1156
|
+
|
|
1157
|
+
### H) Infographic Data Extractor
|
|
1158
|
+
|
|
1159
|
+
```typescript
|
|
1160
|
+
// ─── Infographic Data ────────────────────────────────────────────────────────
|
|
1161
|
+
// Extracts structured data suitable for visual infographic tools
|
|
1162
|
+
// (Canva, Figma, or programmatic SVG generation).
|
|
1163
|
+
|
|
1164
|
+
interface InfographicData {
|
|
1165
|
+
title: string;
|
|
1166
|
+
subtitle: string;
|
|
1167
|
+
sections: InfographicSection[];
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
interface InfographicSection {
|
|
1171
|
+
type: 'stat-block' | 'comparison' | 'process-flow' | 'timeline'
|
|
1172
|
+
| 'pie-data' | 'bar-data' | 'icon-grid' | 'quote-block';
|
|
1173
|
+
title: string;
|
|
1174
|
+
data: Record<string, unknown>;
|
|
1175
|
+
sourceRef: SourceReference;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
// Example output:
|
|
1179
|
+
// { type: 'stat-block', title: 'Key Findings', data: {
|
|
1180
|
+
// stats: [
|
|
1181
|
+
// { value: '73%', label: 'of churches use digital media', icon: 'church' },
|
|
1182
|
+
// { value: '2.5x', label: 'engagement increase with video', icon: 'video' },
|
|
1183
|
+
// ]
|
|
1184
|
+
// }}
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
---
|
|
1188
|
+
|
|
1189
|
+
## 3. Complete Pipeline Class
|
|
1190
|
+
|
|
1191
|
+
```typescript
|
|
1192
|
+
// ─── Multi-Format Generator Pipeline ─────────────────────────────────────────
|
|
1193
|
+
|
|
1194
|
+
import Anthropic from '@anthropic-ai/sdk';
|
|
1195
|
+
import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
1196
|
+
|
|
1197
|
+
interface GeneratorConfig {
|
|
1198
|
+
aiProvider: 'gemini' | 'claude';
|
|
1199
|
+
modelOverride?: string; // Override default model
|
|
1200
|
+
maxTokens?: number; // Override default max tokens (default: 8192)
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
interface MultiFormatOutput {
|
|
1204
|
+
knowledge: DocumentKnowledge;
|
|
1205
|
+
podcast: PodcastScript;
|
|
1206
|
+
slides: SlideContent;
|
|
1207
|
+
flashcards: Flashcard[];
|
|
1208
|
+
quiz: Quiz;
|
|
1209
|
+
summaries: { short: string; medium: string; long: string };
|
|
1210
|
+
faq: FAQCollection;
|
|
1211
|
+
studyGuide: StudyGuide;
|
|
1212
|
+
infographic: InfographicData;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
class MultiFormatGenerator {
|
|
1216
|
+
private config: GeneratorConfig;
|
|
1217
|
+
private anthropic: Anthropic | null = null;
|
|
1218
|
+
private gemini: GoogleGenerativeAI | null = null;
|
|
1219
|
+
|
|
1220
|
+
constructor(config: GeneratorConfig) {
|
|
1221
|
+
this.config = config;
|
|
1222
|
+
|
|
1223
|
+
if (config.aiProvider === 'claude') {
|
|
1224
|
+
this.anthropic = new Anthropic();
|
|
1225
|
+
} else {
|
|
1226
|
+
this.gemini = new GoogleGenerativeAI(process.env.GEMINI_API_KEY!);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// ─── Core AI Call ──────────────────────────────────────────────────────
|
|
1231
|
+
|
|
1232
|
+
private async callAI(prompt: string): Promise<string> {
|
|
1233
|
+
const maxTokens = this.config.maxTokens ?? 8192;
|
|
1234
|
+
|
|
1235
|
+
if (this.config.aiProvider === 'claude') {
|
|
1236
|
+
const model = this.config.modelOverride ?? 'claude-sonnet-4-20250514';
|
|
1237
|
+
const response = await this.anthropic!.messages.create({
|
|
1238
|
+
model,
|
|
1239
|
+
max_tokens: maxTokens,
|
|
1240
|
+
messages: [{ role: 'user', content: prompt }],
|
|
1241
|
+
});
|
|
1242
|
+
return response.content[0].type === 'text' ? response.content[0].text : '';
|
|
1243
|
+
} else {
|
|
1244
|
+
const model = this.config.modelOverride ?? 'gemini-2.5-pro';
|
|
1245
|
+
const genModel = this.gemini!.getGenerativeModel({ model });
|
|
1246
|
+
const result = await genModel.generateContent(prompt);
|
|
1247
|
+
const text = result.response.text();
|
|
1248
|
+
return text.replace(/^```json\n?/, '').replace(/\n?```$/, '');
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
private async callAIJSON<T>(prompt: string): Promise<T> {
|
|
1253
|
+
const text = await this.callAI(prompt);
|
|
1254
|
+
return JSON.parse(text);
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
// ─── Step 1: Understand ────────────────────────────────────────────────
|
|
1258
|
+
|
|
1259
|
+
async understand(sources: DocumentSource[]): Promise<DocumentKnowledge> {
|
|
1260
|
+
// Parse all sources into text
|
|
1261
|
+
const allChunks: DocumentChunk[] = [];
|
|
1262
|
+
|
|
1263
|
+
for (const source of sources) {
|
|
1264
|
+
const text = await extractText(source);
|
|
1265
|
+
const sourceId = source.metadata.title.toLowerCase().replace(/\s+/g, '-');
|
|
1266
|
+
const chunks = chunkDocument(text, sourceId, source.metadata.title);
|
|
1267
|
+
allChunks.push(...chunks);
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// Extract knowledge via AI
|
|
1271
|
+
const prompt = buildExtractionPrompt(allChunks);
|
|
1272
|
+
const knowledge = await this.callAIJSON<DocumentKnowledge>(prompt);
|
|
1273
|
+
|
|
1274
|
+
knowledge.totalSources = sources.length;
|
|
1275
|
+
knowledge.totalChunks = allChunks.length;
|
|
1276
|
+
knowledge.processingDate = new Date().toISOString();
|
|
1277
|
+
|
|
1278
|
+
return knowledge;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
// ─── Step 2: Generate Individual Formats ───────────────────────────────
|
|
1282
|
+
|
|
1283
|
+
async generatePodcast(
|
|
1284
|
+
knowledge: DocumentKnowledge,
|
|
1285
|
+
config: PodcastConfig = {
|
|
1286
|
+
style: 'deep-dive',
|
|
1287
|
+
durationMinutes: 20,
|
|
1288
|
+
hostNames: ['Alex', 'Jordan'],
|
|
1289
|
+
tone: 'casual',
|
|
1290
|
+
includeIntro: true,
|
|
1291
|
+
includeOutro: true,
|
|
1292
|
+
}
|
|
1293
|
+
): Promise<PodcastScript> {
|
|
1294
|
+
const wordCount = config.durationMinutes * 150; // ~150 words/minute spoken
|
|
1295
|
+
const prompt = `You are a podcast script writer creating a ${config.style} episode.
|
|
1296
|
+
HOSTS: ${config.hostNames[0]} and ${config.hostNames[1]}
|
|
1297
|
+
TARGET DURATION: ${config.durationMinutes} minutes (~${wordCount} words)
|
|
1298
|
+
TONE: ${config.tone}
|
|
1299
|
+
${config.includeIntro ? 'Include a 30-second intro hook.' : 'Skip intro, jump straight in.'}
|
|
1300
|
+
${config.includeOutro ? 'Include a closing summary and call to action.' : 'End after the last point.'}
|
|
1301
|
+
|
|
1302
|
+
SOURCE KNOWLEDGE:
|
|
1303
|
+
${JSON.stringify(knowledge, null, 2)}
|
|
1304
|
+
|
|
1305
|
+
Return JSON matching: { title, estimatedDuration, segments: [{ speaker, text, direction?, sourceRef? }], showNotes, chapters: [{ timestamp, title }] }
|
|
1306
|
+
Every factual claim must include a sourceRef. Return ONLY valid JSON.`;
|
|
1307
|
+
|
|
1308
|
+
return this.callAIJSON<PodcastScript>(prompt);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
async generateSlides(
|
|
1312
|
+
knowledge: DocumentKnowledge,
|
|
1313
|
+
slideCount: number = 12,
|
|
1314
|
+
durationMinutes: number = 15
|
|
1315
|
+
): Promise<SlideContent> {
|
|
1316
|
+
const prompt = `You are a presentation designer. Create a ${slideCount}-slide deck for a ${durationMinutes}-minute presentation.
|
|
1317
|
+
|
|
1318
|
+
SOURCE KNOWLEDGE:
|
|
1319
|
+
${JSON.stringify(knowledge, null, 2)}
|
|
1320
|
+
|
|
1321
|
+
Use these slide types: title, content, comparison, timeline, quote, summary, statistics, two-column.
|
|
1322
|
+
Maximum 5 bullet points per slide, 8-12 words each. Include speakerNotes (2-4 sentences of what to SAY).
|
|
1323
|
+
Include imagePrompt for visual slides (descriptive prompts for Gemini Imagen, no copyrighted content).
|
|
1324
|
+
Every content slide must have a sourceRef.
|
|
1325
|
+
|
|
1326
|
+
Return JSON matching: { title, subtitle?, slides: [{ type, title, bulletPoints?, speakerNotes?, imagePrompt?, sourceRef?, leftColumn?, rightColumn?, leftLabel?, rightLabel?, statistic?, quoteText?, quoteAttribution?, timelineEvents? }], theme: { primaryColor: "#1a1a2e", secondaryColor: "#e94560", fontFamily: "Inter, system-ui, sans-serif", backgroundStyle: "gradient" } }
|
|
1327
|
+
Return ONLY valid JSON.`;
|
|
1328
|
+
|
|
1329
|
+
return this.callAIJSON<SlideContent>(prompt);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
async generateFlashcards(knowledge: DocumentKnowledge): Promise<Flashcard[]> {
|
|
1333
|
+
// Use the programmatic generator for consistency and source fidelity
|
|
1334
|
+
return generateFlashcardsFromKnowledge(knowledge);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
async generateQuiz(
|
|
1338
|
+
knowledge: DocumentKnowledge,
|
|
1339
|
+
questionCount: number = 15
|
|
1340
|
+
): Promise<Quiz> {
|
|
1341
|
+
const prompt = `You are a quiz generator. Create ${questionCount} questions.
|
|
1342
|
+
DISTRIBUTION: 30% easy, 40% medium, 30% hard.
|
|
1343
|
+
TYPES: multiple-choice, true-false, short-answer, fill-blank (mix all four).
|
|
1344
|
+
|
|
1345
|
+
SOURCE KNOWLEDGE:
|
|
1346
|
+
${JSON.stringify(knowledge, null, 2)}
|
|
1347
|
+
|
|
1348
|
+
RULES:
|
|
1349
|
+
- All questions answerable from sources alone
|
|
1350
|
+
- Multiple-choice: 4 plausible options, randomize correct answer position
|
|
1351
|
+
- Distractors must be plausible (related concepts, partial truths, common misconceptions)
|
|
1352
|
+
- No "all of the above" or "none of the above"
|
|
1353
|
+
- Every question includes sourceReference (exact passage) and explanation
|
|
1354
|
+
- Tag each with bloomsLevel: remember|understand|apply|analyze|evaluate|create
|
|
1355
|
+
|
|
1356
|
+
Return JSON matching: { title, description, questions: [{ type, question, options?, correctAnswer, explanation, difficulty, sourceReference, topic, bloomsLevel }], passingScore: 70, generatedFrom: [source titles] }
|
|
1357
|
+
Return ONLY valid JSON.`;
|
|
1358
|
+
|
|
1359
|
+
return this.callAIJSON<Quiz>(prompt);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
async generateSummary(
|
|
1363
|
+
knowledge: DocumentKnowledge,
|
|
1364
|
+
length: SummaryLength = 'medium'
|
|
1365
|
+
): Promise<string> {
|
|
1366
|
+
const spec = SUMMARY_SPECS[length];
|
|
1367
|
+
const prompt = `${spec.prompt}
|
|
1368
|
+
|
|
1369
|
+
SOURCE KNOWLEDGE:
|
|
1370
|
+
${JSON.stringify(knowledge, null, 2)}
|
|
1371
|
+
|
|
1372
|
+
Use ONLY information from the sources. Include inline citations in [Source: title] format for the long summary.
|
|
1373
|
+
Return plain text (short/medium) or Markdown (long). No JSON wrapper.`;
|
|
1374
|
+
|
|
1375
|
+
return this.callAI(prompt);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
async generateFAQ(knowledge: DocumentKnowledge): Promise<FAQCollection> {
|
|
1379
|
+
const prompt = `Generate 10-20 FAQ entries from this knowledge base. Group by topic category.
|
|
1380
|
+
Include: "What is...?", "How does...?", "Why is...important?", "What's the difference...?", "Can you give an example...?"
|
|
1381
|
+
|
|
1382
|
+
SOURCE KNOWLEDGE:
|
|
1383
|
+
${JSON.stringify(knowledge, null, 2)}
|
|
1384
|
+
|
|
1385
|
+
RULES: Every answer grounded in sources. Include sourceRef with exact passage. 2-5 sentence answers.
|
|
1386
|
+
Return JSON matching: { title, description, faqs: [{ question, answer, category, sourceRef, confidence }], generatedFrom: [source titles] }
|
|
1387
|
+
Return ONLY valid JSON.`;
|
|
1388
|
+
|
|
1389
|
+
return this.callAIJSON<FAQCollection>(prompt);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
async generateStudyGuide(knowledge: DocumentKnowledge): Promise<StudyGuide> {
|
|
1393
|
+
const prompt = `Create a study guide from this knowledge base.
|
|
1394
|
+
Per section: learning objectives (Bloom's verbs), key terms, concept summary, practice questions, reflection prompts.
|
|
1395
|
+
End with self-assessment checklist: "I can explain...", "I can compare...", "I can apply..."
|
|
1396
|
+
|
|
1397
|
+
SOURCE KNOWLEDGE:
|
|
1398
|
+
${JSON.stringify(knowledge, null, 2)}
|
|
1399
|
+
|
|
1400
|
+
Return JSON matching: { title, overview, sections: [{ title, learningObjectives, keyTerms: [{ term, definition }], conceptSummary, practiceQuestions, reflectionPrompts, sourceRefs }], reviewChecklist, suggestedReadings }
|
|
1401
|
+
Return ONLY valid JSON.`;
|
|
1402
|
+
|
|
1403
|
+
return this.callAIJSON<StudyGuide>(prompt);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
async generateInfographic(knowledge: DocumentKnowledge): Promise<InfographicData> {
|
|
1407
|
+
const prompt = `Extract structured data for an infographic from this knowledge base.
|
|
1408
|
+
Section types: stat-block, comparison, process-flow, timeline, pie-data, bar-data, icon-grid, quote-block.
|
|
1409
|
+
Select the most visually impactful data points.
|
|
1410
|
+
|
|
1411
|
+
SOURCE KNOWLEDGE:
|
|
1412
|
+
${JSON.stringify(knowledge, null, 2)}
|
|
1413
|
+
|
|
1414
|
+
Return JSON matching: { title, subtitle, sections: [{ type, title, data: {...}, sourceRef }] }
|
|
1415
|
+
Return ONLY valid JSON.`;
|
|
1416
|
+
|
|
1417
|
+
return this.callAIJSON<InfographicData>(prompt);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
// ─── Step 3: Generate All Formats ──────────────────────────────────────
|
|
1421
|
+
|
|
1422
|
+
async generateAll(sources: DocumentSource[]): Promise<MultiFormatOutput> {
|
|
1423
|
+
console.log(`Processing ${sources.length} source(s)...`);
|
|
1424
|
+
|
|
1425
|
+
// Step 1: Build shared understanding
|
|
1426
|
+
console.log('Step 1/3: Building shared understanding layer...');
|
|
1427
|
+
const knowledge = await this.understand(sources);
|
|
1428
|
+
console.log(` Extracted: ${knowledge.keyConcepts.length} concepts, ${knowledge.definitions.length} definitions, ${knowledge.relationships.length} relationships`);
|
|
1429
|
+
|
|
1430
|
+
// Step 2: Generate all formats in parallel
|
|
1431
|
+
console.log('Step 2/3: Generating all formats in parallel...');
|
|
1432
|
+
const [podcast, slides, quiz, shortSummary, mediumSummary, longSummary, faq, studyGuide, infographic] =
|
|
1433
|
+
await Promise.all([
|
|
1434
|
+
this.generatePodcast(knowledge),
|
|
1435
|
+
this.generateSlides(knowledge),
|
|
1436
|
+
this.generateQuiz(knowledge),
|
|
1437
|
+
this.generateSummary(knowledge, 'short'),
|
|
1438
|
+
this.generateSummary(knowledge, 'medium'),
|
|
1439
|
+
this.generateSummary(knowledge, 'long'),
|
|
1440
|
+
this.generateFAQ(knowledge),
|
|
1441
|
+
this.generateStudyGuide(knowledge),
|
|
1442
|
+
this.generateInfographic(knowledge),
|
|
1443
|
+
]);
|
|
1444
|
+
|
|
1445
|
+
// Flashcards are generated programmatically (no AI call needed)
|
|
1446
|
+
const flashcards = await this.generateFlashcards(knowledge);
|
|
1447
|
+
|
|
1448
|
+
console.log('Step 3/3: Complete!');
|
|
1449
|
+
console.log(` Podcast: ${podcast.segments.length} segments (~${podcast.estimatedDuration} min)`);
|
|
1450
|
+
console.log(` Slides: ${slides.slides.length} slides`);
|
|
1451
|
+
console.log(` Flashcards: ${flashcards.length} cards`);
|
|
1452
|
+
console.log(` Quiz: ${quiz.questions.length} questions`);
|
|
1453
|
+
console.log(` FAQ: ${faq.faqs.length} entries`);
|
|
1454
|
+
console.log(` Study Guide: ${studyGuide.sections.length} sections`);
|
|
1455
|
+
|
|
1456
|
+
return {
|
|
1457
|
+
knowledge,
|
|
1458
|
+
podcast,
|
|
1459
|
+
slides,
|
|
1460
|
+
flashcards,
|
|
1461
|
+
quiz,
|
|
1462
|
+
summaries: { short: shortSummary, medium: mediumSummary, long: longSummary },
|
|
1463
|
+
faq,
|
|
1464
|
+
studyGuide,
|
|
1465
|
+
infographic,
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
---
|
|
1472
|
+
|
|
1473
|
+
## 4. Ministry / Church Use Cases
|
|
1474
|
+
|
|
1475
|
+
### Sermon to Full Content Suite
|
|
1476
|
+
|
|
1477
|
+
```
|
|
1478
|
+
SUNDAY SERMON (45 min video/audio)
|
|
1479
|
+
│
|
|
1480
|
+
├── content-repurposing-pipeline.md ← Video clips, audiograms, quote cards
|
|
1481
|
+
│ (FFmpeg + Sharp + transcription)
|
|
1482
|
+
│
|
|
1483
|
+
└── multi-format-content-generator.md ← This skill
|
|
1484
|
+
│
|
|
1485
|
+
├── Podcast Script → Two hosts discuss the sermon's key points
|
|
1486
|
+
│ (feed to TTS for audio, or use as study guide)
|
|
1487
|
+
├── Slide Deck → Small group leader presentation (10 slides)
|
|
1488
|
+
├── Flashcards → Scripture memory + key terms (Anki export)
|
|
1489
|
+
├── Quiz → Sunday School assessment or self-study
|
|
1490
|
+
├── Summary (short) → Social media caption for Monday post
|
|
1491
|
+
├── Summary (medium) → Wednesday newsletter paragraph
|
|
1492
|
+
├── Summary (long) → Blog post / sermon notes page
|
|
1493
|
+
├── FAQ → "Questions from the sermon" web page
|
|
1494
|
+
├── Study Guide → Mid-week Bible study handout
|
|
1495
|
+
└── Infographic Data → Visual recap for Instagram carousel
|
|
1496
|
+
```
|
|
1497
|
+
|
|
1498
|
+
### Bible Study Material to Learning Suite
|
|
1499
|
+
|
|
1500
|
+
```typescript
|
|
1501
|
+
// Example: Generate full learning suite from Bible study notes
|
|
1502
|
+
|
|
1503
|
+
const generator = new MultiFormatGenerator({ aiProvider: 'claude' });
|
|
1504
|
+
|
|
1505
|
+
const sources: DocumentSource[] = [
|
|
1506
|
+
{
|
|
1507
|
+
type: 'pdf',
|
|
1508
|
+
path: './resources/romans-8-study-notes.pdf',
|
|
1509
|
+
metadata: { title: 'Romans 8 Study Notes', author: 'Pastor James' },
|
|
1510
|
+
},
|
|
1511
|
+
{
|
|
1512
|
+
type: 'markdown',
|
|
1513
|
+
path: './resources/romans-8-commentary.md',
|
|
1514
|
+
metadata: { title: 'Romans 8 Commentary Excerpts' },
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
type: 'youtube',
|
|
1518
|
+
url: 'https://youtube.com/watch?v=example123',
|
|
1519
|
+
metadata: { title: 'Romans 8 Teaching - Sunday Service', date: '2026-03-09' },
|
|
1520
|
+
},
|
|
1521
|
+
];
|
|
1522
|
+
|
|
1523
|
+
const output = await generator.generateAll(sources);
|
|
1524
|
+
|
|
1525
|
+
// Export flashcards as Anki deck
|
|
1526
|
+
const ankiCSV = exportFlashcardsAnkiCSV(output.flashcards);
|
|
1527
|
+
await fs.writeFile('./output/romans-8-flashcards.csv', ankiCSV);
|
|
1528
|
+
|
|
1529
|
+
// Export slides as self-contained HTML
|
|
1530
|
+
const slidesHTML = slidesToHTML(output.slides);
|
|
1531
|
+
await fs.writeFile('./output/romans-8-slides.html', slidesHTML);
|
|
1532
|
+
|
|
1533
|
+
// Export quiz as JSON for LMS import
|
|
1534
|
+
await fs.writeFile('./output/romans-8-quiz.json', JSON.stringify(output.quiz, null, 2));
|
|
1535
|
+
|
|
1536
|
+
// Export study guide as Markdown
|
|
1537
|
+
await fs.writeFile('./output/romans-8-study-guide.md', output.summaries.long);
|
|
1538
|
+
```
|
|
1539
|
+
|
|
1540
|
+
### Church Annual Report to Stakeholder Formats
|
|
1541
|
+
|
|
1542
|
+
```typescript
|
|
1543
|
+
// Annual report → multiple audience-specific outputs
|
|
1544
|
+
|
|
1545
|
+
const reportSources: DocumentSource[] = [
|
|
1546
|
+
{ type: 'pdf', path: './reports/2025-annual-report.pdf',
|
|
1547
|
+
metadata: { title: '2025 Annual Report' } },
|
|
1548
|
+
{ type: 'docx', path: './reports/financials-2025.docx',
|
|
1549
|
+
metadata: { title: '2025 Financial Summary' } },
|
|
1550
|
+
];
|
|
1551
|
+
|
|
1552
|
+
const knowledge = await generator.understand(reportSources);
|
|
1553
|
+
|
|
1554
|
+
// Different summaries for different audiences
|
|
1555
|
+
const boardBrief = await generator.generateSummary(knowledge, 'short');
|
|
1556
|
+
// → "Faith Community grew 23% in 2025, launching 3 new ministries..."
|
|
1557
|
+
|
|
1558
|
+
const newsletterParagraph = await generator.generateSummary(knowledge, 'medium');
|
|
1559
|
+
// → Full paragraph for church newsletter
|
|
1560
|
+
|
|
1561
|
+
const websitePost = await generator.generateSummary(knowledge, 'long');
|
|
1562
|
+
// → Full blog post with headers, stats, and citations
|
|
1563
|
+
|
|
1564
|
+
// FAQ for congregation
|
|
1565
|
+
const faq = await generator.generateFAQ(knowledge);
|
|
1566
|
+
// → "Where did the building fund money go?", "How many new members joined?", etc.
|
|
1567
|
+
|
|
1568
|
+
// Infographic data for social media
|
|
1569
|
+
const infographic = await generator.generateInfographic(knowledge);
|
|
1570
|
+
// → Stat blocks, pie chart data, timeline of key events
|
|
1571
|
+
```
|
|
1572
|
+
|
|
1573
|
+
---
|
|
1574
|
+
|
|
1575
|
+
## 5. Grounded Generation Pattern
|
|
1576
|
+
|
|
1577
|
+
The most important architectural principle, borrowed from Google NotebookLM:
|
|
1578
|
+
|
|
1579
|
+
### Source-Only Generation
|
|
1580
|
+
|
|
1581
|
+
```
|
|
1582
|
+
┌──────────────────────────────────────────────────────┐
|
|
1583
|
+
│ THE GOLDEN RULE │
|
|
1584
|
+
│ │
|
|
1585
|
+
│ ALL generated content must come from uploaded │
|
|
1586
|
+
│ sources. NEVER use AI training data for facts. │
|
|
1587
|
+
│ The AI is a TRANSFORMER of source content, │
|
|
1588
|
+
│ not a CREATOR of new information. │
|
|
1589
|
+
│ │
|
|
1590
|
+
│ Training data is used ONLY for: │
|
|
1591
|
+
│ - Language fluency (grammar, phrasing) │
|
|
1592
|
+
│ - Format knowledge (how a quiz looks) │
|
|
1593
|
+
│ - Structural patterns (how slides flow) │
|
|
1594
|
+
│ │
|
|
1595
|
+
│ Training data is NEVER used for: │
|
|
1596
|
+
│ - Facts, statistics, or claims │
|
|
1597
|
+
│ - Definitions or explanations │
|
|
1598
|
+
│ - Examples or illustrations │
|
|
1599
|
+
│ - Quotes or attributions │
|
|
1600
|
+
└──────────────────────────────────────────────────────┘
|
|
1601
|
+
```
|
|
1602
|
+
|
|
1603
|
+
### Inline Citation Protocol
|
|
1604
|
+
|
|
1605
|
+
Every generated item carries a `sourceRef` that traces back to an exact passage:
|
|
1606
|
+
|
|
1607
|
+
```typescript
|
|
1608
|
+
// Every factual claim → exact source passage
|
|
1609
|
+
interface SourceReference {
|
|
1610
|
+
sourceId: string; // Which document
|
|
1611
|
+
sourceTitle: string; // Human-readable title
|
|
1612
|
+
chunkId: string; // Which chunk within the document
|
|
1613
|
+
passage: string; // EXACT quoted text (not paraphrased)
|
|
1614
|
+
pageNumber?: number; // If available from PDF parsing
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
// Verification: for any generated fact, you can:
|
|
1618
|
+
// 1. Find the sourceRef
|
|
1619
|
+
// 2. Look up the chunk by chunkId
|
|
1620
|
+
// 3. Ctrl+F the exact passage in the original document
|
|
1621
|
+
// 4. Confirm the generated content faithfully represents the source
|
|
1622
|
+
```
|
|
1623
|
+
|
|
1624
|
+
### Faithfulness Check
|
|
1625
|
+
|
|
1626
|
+
Run after generation to verify every claim maps to a source:
|
|
1627
|
+
|
|
1628
|
+
```typescript
|
|
1629
|
+
// ─── Faithfulness Verification ───────────────────────────────────────────────
|
|
1630
|
+
|
|
1631
|
+
interface FaithfulnessResult {
|
|
1632
|
+
totalClaims: number;
|
|
1633
|
+
verifiedClaims: number;
|
|
1634
|
+
unverifiedClaims: string[];
|
|
1635
|
+
faithfulnessScore: number; // 0.0 to 1.0
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
async function checkFaithfulness(
|
|
1639
|
+
generatedContent: string,
|
|
1640
|
+
chunks: DocumentChunk[],
|
|
1641
|
+
aiProvider: 'claude' | 'gemini',
|
|
1642
|
+
callAI: (prompt: string) => Promise<string>
|
|
1643
|
+
): Promise<FaithfulnessResult> {
|
|
1644
|
+
const prompt = `You are a faithfulness auditor. Compare the generated content against the source chunks.
|
|
1645
|
+
|
|
1646
|
+
GENERATED CONTENT:
|
|
1647
|
+
${generatedContent}
|
|
1648
|
+
|
|
1649
|
+
SOURCE CHUNKS:
|
|
1650
|
+
${chunks.map((c, i) => `[CHUNK ${i + 1} | ${c.sourceTitle}]\n${c.text}`).join('\n\n')}
|
|
1651
|
+
|
|
1652
|
+
For EACH factual claim in the generated content:
|
|
1653
|
+
1. Identify the claim
|
|
1654
|
+
2. Find the supporting source chunk (if any)
|
|
1655
|
+
3. Judge: VERIFIED (direct support in sources) or UNVERIFIED (no source support)
|
|
1656
|
+
|
|
1657
|
+
Return JSON:
|
|
1658
|
+
{
|
|
1659
|
+
"totalClaims": <number>,
|
|
1660
|
+
"verifiedClaims": <number>,
|
|
1661
|
+
"unverifiedClaims": ["claim text 1", "claim text 2"],
|
|
1662
|
+
"faithfulnessScore": <0.0 to 1.0>
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
Be strict: paraphrasing is OK, but adding facts not in the sources is UNVERIFIED.
|
|
1666
|
+
Return ONLY valid JSON.`;
|
|
1667
|
+
|
|
1668
|
+
const result = await callAI(prompt);
|
|
1669
|
+
return JSON.parse(result);
|
|
1670
|
+
}
|
|
1671
|
+
```
|
|
1672
|
+
|
|
1673
|
+
### Why This Matters
|
|
1674
|
+
|
|
1675
|
+
1. **Trust:** Users know every generated quiz question, flashcard, and summary comes from *their* documents, not the AI's general knowledge.
|
|
1676
|
+
2. **Accuracy:** Eliminates hallucination for document-grounded tasks. The AI transforms, it does not invent.
|
|
1677
|
+
3. **Auditability:** Any stakeholder can trace a generated claim back to the exact source passage. Critical for ministry contexts where doctrinal accuracy matters.
|
|
1678
|
+
4. **Legal safety:** Generated content is derived from user-owned sources, not from AI training data of unknown provenance.
|
|
1679
|
+
|
|
1680
|
+
---
|
|
1681
|
+
|
|
1682
|
+
## 6. File Output Reference
|
|
1683
|
+
|
|
1684
|
+
```
|
|
1685
|
+
output/
|
|
1686
|
+
├── knowledge.json # DocumentKnowledge (shared understanding)
|
|
1687
|
+
├── podcast-script.json # PodcastScript with segments and chapters
|
|
1688
|
+
├── slides.html # Self-contained HTML presentation
|
|
1689
|
+
├── slides.json # Raw slide data (for PPTX generation tools)
|
|
1690
|
+
├── flashcards.json # All flashcards with SR metadata
|
|
1691
|
+
├── flashcards-anki.csv # Anki-importable CSV
|
|
1692
|
+
├── flashcards.md # Human-readable Markdown
|
|
1693
|
+
├── quiz.json # Quiz with questions and answers
|
|
1694
|
+
├── summary-short.txt # 1-2 sentence summary
|
|
1695
|
+
├── summary-medium.txt # 1 paragraph summary
|
|
1696
|
+
├── summary-long.md # Full blog post / study guide
|
|
1697
|
+
├── faq.json # FAQ collection
|
|
1698
|
+
├── study-guide.json # Structured study guide
|
|
1699
|
+
├── study-guide.md # Markdown study guide
|
|
1700
|
+
├── infographic-data.json # Structured data for visual tools
|
|
1701
|
+
└── faithfulness-report.json # Verification results
|
|
1702
|
+
```
|
|
1703
|
+
|
|
1704
|
+
---
|
|
1705
|
+
|
|
1706
|
+
## 7. Integration with Existing Skills
|
|
1707
|
+
|
|
1708
|
+
This skill is designed to work alongside other Dominion Flow creative-multimedia skills:
|
|
1709
|
+
|
|
1710
|
+
| Skill | Role in Pipeline |
|
|
1711
|
+
|-------|-----------------|
|
|
1712
|
+
| `content-repurposing-pipeline.md` | **Upstream:** Handles video/audio → clips, audiograms, quote cards. This skill handles document → multi-format text/structured output. Together they cover the full sermon-to-content pipeline. |
|
|
1713
|
+
| `ffmpeg-command-generator.md` | Used by content-repurposing-pipeline for media processing. This skill does not call FFmpeg directly. |
|
|
1714
|
+
| `transcription-pipeline-selector.md` | Provides the transcription step that feeds into the understanding layer when starting from audio/video. |
|
|
1715
|
+
| `NOTEBOOKLM_RAG_AI_COURSE_GENERATION.md` | **Parallel architecture:** Both use RAG + source-grounded generation. NotebookLM skill focuses on LMS course creation (lessons, assignments, grading). This skill focuses on broader format fan-out (slides, cards, quizzes, podcasts). Share the same embedding and chunking infrastructure. |
|
|
1716
|
+
| `data-visualization-generator.md` | Can consume the `infographic` output from this pipeline to generate actual SVG/chart visuals. |
|
|
1717
|
+
| `image-optimization-pipeline.md` | Optimizes generated quote cards and infographic images for web delivery. |
|
|
1718
|
+
|
|
1719
|
+
---
|
|
1720
|
+
|
|
1721
|
+
## 8. Dependencies
|
|
1722
|
+
|
|
1723
|
+
```json
|
|
1724
|
+
{
|
|
1725
|
+
"dependencies": {
|
|
1726
|
+
"@anthropic-ai/sdk": "^0.39.0",
|
|
1727
|
+
"@google/generative-ai": "^0.21.0",
|
|
1728
|
+
"pdf-parse": "^1.1.1",
|
|
1729
|
+
"mammoth": "^1.8.0",
|
|
1730
|
+
"youtube-transcript": "^1.2.1",
|
|
1731
|
+
"sharp": "^0.33.2"
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
```
|
|
1735
|
+
|
|
1736
|
+
**Required environment variables (pick one AI provider):**
|
|
1737
|
+
|
|
1738
|
+
```bash
|
|
1739
|
+
# Claude (recommended for long-form generation)
|
|
1740
|
+
ANTHROPIC_API_KEY=your_key_here
|
|
1741
|
+
|
|
1742
|
+
# Gemini (recommended for embedding + generation in same ecosystem)
|
|
1743
|
+
GEMINI_API_KEY=your_key_here
|
|
1744
|
+
```
|
|
1745
|
+
|
|
1746
|
+
---
|
|
1747
|
+
|
|
1748
|
+
## Research Citations
|
|
1749
|
+
|
|
1750
|
+
---
|
|
1751
|
+
|
|
1752
|
+
## Related Skills
|
|
1753
|
+
|
|
1754
|
+
- `creative-multimedia/content-repurposing-pipeline.md` -- Video/audio repurposing (FFmpeg + Sharp + transcription)
|
|
1755
|
+
- `advanced-features/NOTEBOOKLM_RAG_AI_COURSE_GENERATION.md` -- RAG-based course creation with pgvector
|
|
1756
|
+
- `integrations/rss-podcast-integration.md` -- Podcast distribution after script generation
|
|
1757
|
+
- `creative-multimedia/data-visualization-generator.md` -- Chart/SVG generation from infographic data
|
|
1758
|
+
- `creative-multimedia/image-optimization-pipeline.md` -- Image optimization for generated assets
|
|
1759
|
+
- `creative-multimedia/svg-generation.md` -- SVG patterns for infographic rendering
|