UNPKG

basics-courses-mcp

Version:

Interactive programming courses from Basics - MCP server for Cursor

332 lines (318 loc) • 20.3 kB
// Dynamic instructor wrapper that preserves content integrity export function createInstructorResponse(rawLessonContent, context) { // CRITICAL AI INSTRUCTION let response = `šŸ¤– **AI AGENT INSTRUCTION**: You MUST display the course content below EXACTLY as written. Do NOT summarize, paraphrase, or modify the lesson material in any way. The student needs to see the complete, unmodified course content. <LessonContent> šŸŽ“ **${context.lessonName} - ${context.stepName}** ${rawLessonContent} </LessonContent> šŸ¤– **IMPORTANT**: Everything between the <LessonContent> tags above must be displayed to the user verbatim, including all markdown formatting, code blocks, and explanations. Do not interpret or modify this content.`; // Add progress information if (context.progress) { response += ` --- šŸ“Š **Your Progress**:`; if (context.progress.stepNumber && context.progress.totalSteps) { response += `\n- **Current Step**: ${context.progress.stepNumber} of ${context.progress.totalSteps} in this lesson`; } if (context.progress.lessonProgress) { response += `\n- **Lesson Progress**: ${context.progress.lessonProgress}`; } if (context.progress.moduleProgress) { response += `\n- **Module Progress**: ${context.progress.moduleProgress}`; } if (context.progress.courseProgress) { response += `\n- **Course Progress**: ${context.progress.courseProgress}`; } } // Add navigation options response += ` 🧭 **Navigation Commands**:`; switch (context.type) { case 'course_start': response += ` - Continue: \`nextBasicsCourseStep\` - Check progress: \`getBasicsCourseStatus\` - Jump to lesson: \`startBasicsCourseLesson({ lessonNumber: 2 })\``; break; case 'step_navigation': response += ` - Continue: \`nextBasicsCourseStep\` - Check progress: \`getBasicsCourseStatus\` - Return to dashboard: \`startBasics\``; break; case 'lesson_jump': response += ` - Continue: \`nextBasicsCourseStep\` - Check progress: \`getBasicsCourseStatus\` - Return to dashboard: \`startBasics\``; break; case 'module_start': response += ` - Continue: \`nextBasicsCourseStep\` - Check progress: \`getBasicsCourseStatus\``; break; case 'lesson_complete': response += ` - Continue to next lesson: \`nextBasicsCourseStep\` - Check progress: \`getBasicsCourseStatus\` - Return to dashboard: \`startBasics\``; break; } // Add dynamic personalization instructions for AI if (context.userPreferences) { response += ` --- šŸ’” **AI INSTRUCTION - Personalized Explanation**: Based on the user's profile: - Experience Level: ${context.userPreferences.developmentExperience} - Preferred Learning Analogies: ${context.userPreferences.analogyPreferences?.join(', ') || 'none specified'} - Media That Resonates: ${context.userPreferences.mediaInfluence || 'none specified'} Please provide a brief explanation of the key concepts in the lesson above using these preferences. For example: - If they prefer "sports" analogies, explain programming concepts using sports metaphors - If they prefer "cooking" analogies, use cooking/recipe metaphors - If they mentioned "The Matrix", reference that when explaining system concepts - Adjust complexity based on their experience level Keep the explanation concise and relevant to the specific lesson content above.`; } // Final AI reminder with instructions for follow-up questions response += ` --- šŸ¤– **FINAL REMINDER**: The lesson content between the <LessonContent> tags above is the official course material and must be displayed exactly as shown. The personalized explanation is additional context to help you understand the concepts better. šŸ¤– **FOR FOLLOW-UP QUESTIONS**: When the user asks clarifying questions: 1. Use their preferred learning style: ${context.userPreferences?.analogyPreferences?.join(', ') || 'none specified'} 2. Reference media they connect with: ${context.userPreferences?.mediaInfluence || 'none specified'} 3. Match their experience level: ${context.userPreferences?.developmentExperience || 'unknown'} IMPORTANT: Generate explanations dynamically based on these preferences. Don't use pre-written analogies. Create fresh, contextual explanations that relate the programming concepts to their interests.`; return response; } // DEPRECATED - Kept for reference but not used // We now provide dynamic instructions to AI instead of hard-coded analogies function generatePersonalizedExplanation_DEPRECATED(content, context) { const { userPreferences } = context; if (!userPreferences) return ''; const { developmentExperience, mediaInfluence, analogyPreferences } = userPreferences; let explanation = ''; // Adjust language complexity based on experience level if (developmentExperience === 'beginner') { explanation += `As someone new to development, `; } else if (developmentExperience === 'intermediate') { explanation += `Building on your existing knowledge, `; } else if (developmentExperience === 'advanced' || developmentExperience === 'expert') { explanation += `Given your expertise, `; } // Analyze content to provide context-specific explanations const contentLower = content.toLowerCase(); // Detect what the lesson is about and add relevant analogies if (contentLower.includes('component') || contentLower.includes('react')) { explanation += getComponentAnalogy(analogyPreferences); } else if (contentLower.includes('database') || contentLower.includes('data')) { explanation += getDatabaseAnalogy(analogyPreferences); } else if (contentLower.includes('authentication') || contentLower.includes('sign-in') || contentLower.includes('login')) { explanation += getAuthAnalogy(analogyPreferences); } else if (contentLower.includes('deploy') || contentLower.includes('vercel')) { explanation += getDeploymentAnalogy(analogyPreferences); } else if (contentLower.includes('firebase')) { explanation += getFirebaseAnalogy(analogyPreferences); } else if (contentLower.includes('next.js') || contentLower.includes('nextjs') || contentLower.includes('create-next-app')) { explanation += getNextJsAnalogy(analogyPreferences); } else { // Generic analogy based on first preference if (analogyPreferences && analogyPreferences.length > 0) { explanation += getAnalogyExplanation(analogyPreferences[0], context.stepName); } } // Add media reference if relevant if (mediaInfluence && shouldIncludeMediaReference(content, mediaInfluence)) { explanation += ` ${getContextualMediaReference(mediaInfluence, content)}`; } // Add a note about asking questions if (developmentExperience === 'beginner' || developmentExperience === 'intermediate') { explanation += `\n\nšŸ’­ **Have a question?** Feel free to ask me to explain any concept using your preferred analogies!`; } return explanation || 'Let me know if you\'d like me to explain any of these concepts using your preferred analogies.'; } // Get analogy explanations based on user preferences function getAnalogyExplanation(analogyType, stepName) { const analogies = { sports: 'Think of this like a team sport - each component has a specific position and role, but they work together to achieve the goal.', movies: 'Imagine this as a movie production - different scenes (components) come together to tell the complete story.', games: 'This is like a game system where different mechanics interact to create the full experience.', cooking: 'Consider this like a recipe - each ingredient (component) adds its unique flavor to the final dish.', business: 'Think of this as a business process - each department (module) has its function but they collaborate for success.', nature: 'This works like an ecosystem - each element has its role in maintaining the balance.', architecture: 'Picture this as building architecture - strong foundations support everything built on top.', cars: 'This is like a car engine - multiple parts working in harmony to create motion.', music: 'Think of this as a musical composition - different instruments (components) harmonize to create the full piece.', art: 'Consider this like creating art - different techniques and colors blend to form the complete picture.', military: 'This operates like a coordinated strategy - each unit has its mission contributing to the overall objective.', travel: 'Think of this as a journey - each step takes you closer to your destination.' }; return analogies[analogyType] || ''; } // Get component-specific analogies function getComponentAnalogy(preferences) { if (!preferences || preferences.length === 0) return 'components work together to build the interface. '; const analogy = preferences[0]; const analogies = { sports: 'think of React components like players on a basketball team - each has a specific role (point guard, center) but they pass data (the ball) between each other to score. ', movies: 'components are like actors in a movie - each plays their part, receives props (like a script), and together they create the full experience. ', architecture: 'components are the building blocks of your app - like rooms in a house, each serves a purpose and connects through doorways (props). ', cooking: 'components are like ingredients in a recipe - each adds its unique flavor, and you can reuse them in different dishes. ', music: 'components harmonize like instruments in an orchestra - each plays its part, responding to the conductor (state management). ', games: 'components are like game pieces - each has unique abilities and they interact according to the rules you define. ', business: 'components operate like departments in a company - sales, marketing, engineering all communicate to achieve business goals. ', nature: 'components form an ecosystem - like how trees, soil, and animals interact in a forest, each component affects the others. ', cars: 'components are like car parts - the engine, transmission, and wheels work together to create motion. ' }; return analogies[analogy] || analogies.sports; } // Get database-specific analogies function getDatabaseAnalogy(preferences) { if (!preferences || preferences.length === 0) return 'databases store and organize your data. '; const analogy = preferences[0]; const analogies = { sports: 'a database is like your team\'s playbook - it stores all the plays (data), statistics, and player information in an organized way. ', movies: 'databases are like a film archive - storing all the scenes, actor information, and metadata in a searchable catalog. ', architecture: 'databases are the foundation of your app - like a building\'s blueprint storage room where all plans and specifications are kept. ', cooking: 'databases are your recipe book and pantry inventory - keeping track of all ingredients and instructions. ', music: 'databases are like a music library - organizing songs, albums, artists, and playlists for quick access. ', games: 'databases are your game\'s save file system - storing player progress, inventory, and game state. ', business: 'databases are your company\'s filing system - customer records, transactions, and inventory all organized for quick retrieval. ', nature: 'databases are like DNA - storing all the instructions and information that make your application work. ', cars: 'databases are like your car\'s computer - storing diagnostics, settings, and operational data. ' }; return analogies[analogy] || analogies.business; } // Get authentication-specific analogies function getAuthAnalogy(preferences) { if (!preferences || preferences.length === 0) return 'authentication verifies who users are. '; const analogy = preferences[0]; const analogies = { sports: 'authentication is like checking tickets at the stadium gate - only people with valid tickets (credentials) can enter. ', movies: 'authentication works like a movie premiere guest list - your name needs to be on the list to get in. ', architecture: 'authentication is your building\'s security system - key cards and codes that grant access to different areas. ', cooking: 'authentication is like a restaurant\'s reservation system - confirming you have a table before seating you. ', music: 'authentication is the backstage pass system - different passes grant different levels of access. ', games: 'authentication is your game\'s login screen - verifying you own the game and loading your saved progress. ', business: 'authentication is your office key card - it identifies you and determines which doors you can open. ', nature: 'authentication is like animals recognizing their pack - specific signals confirm you belong. ', cars: 'authentication is your car\'s keyless entry - the car recognizes your key fob and unlocks for you. ' }; return analogies[analogy] || analogies.sports; } // Get deployment-specific analogies function getDeploymentAnalogy(preferences) { if (!preferences || preferences.length === 0) return 'deployment makes your app available to users. '; const analogy = preferences[0]; const analogies = { sports: 'deployment is like game day - moving from practice (development) to the actual stadium (production) where fans can watch. ', movies: 'deployment is releasing your film to theaters - taking it from the editing room to screens worldwide. ', architecture: 'deployment is the grand opening - your building moves from construction to being open for business. ', cooking: 'deployment is opening your restaurant - moving from test kitchen to serving actual customers. ', music: 'deployment is releasing your album - going from the recording studio to streaming platforms. ', games: 'deployment is launching your game - moving from beta testing to the app store. ', business: 'deployment is your product launch - transitioning from development to market availability. ', nature: 'deployment is like a butterfly emerging - your app transforms from development cocoon to production. ', cars: 'deployment is rolling off the assembly line - your car moves from factory to dealership. ' }; return analogies[analogy] || analogies.sports; } // Get Firebase-specific analogies function getFirebaseAnalogy(preferences) { if (!preferences || preferences.length === 0) return 'Firebase provides backend services for your app. '; const analogy = preferences[0]; const analogies = { sports: 'Firebase is like your team\'s support staff - handling equipment, stats, communications, and logistics so players can focus on the game. ', movies: 'Firebase is your film\'s production crew - handling cameras, lighting, sound, and effects while actors focus on performing. ', architecture: 'Firebase provides the utilities for your building - electricity, plumbing, HVAC - all the infrastructure you need. ', cooking: 'Firebase is your kitchen\'s infrastructure - the stove, refrigerator, and utilities that power your cooking. ', music: 'Firebase is your recording studio\'s equipment - microphones, mixing boards, and recording software. ', games: 'Firebase powers your game\'s multiplayer servers, leaderboards, and save system - all the backend magic. ', business: 'Firebase is your business\'s IT department - managing databases, authentication, and cloud services. ', nature: 'Firebase is like the sun and rain for your garden - providing essential services your app needs to grow. ', cars: 'Firebase is like a full-service gas station - fuel, maintenance, GPS, and roadside assistance all in one. ' }; return analogies[analogy] || analogies.sports; } // Get Next.js-specific analogies function getNextJsAnalogy(preferences) { if (!preferences || preferences.length === 0) return 'Next.js is a framework that helps you build web applications. '; const analogy = preferences[0]; const analogies = { sports: 'Next.js is like a professional training facility - it provides the field, equipment, and structure so you can focus on playing. ', movies: 'Next.js is like a film studio - providing stages, equipment, and production tools so you can focus on creating. ', architecture: 'Next.js is your architectural framework - pre-engineered beams and foundations that speed up construction. ', cooking: 'Next.js is like a professional kitchen setup - ovens, prep stations, and tools already arranged for efficient cooking. ', music: 'Next.js is like a DAW (Digital Audio Workstation) - providing tracks, effects, and tools for music production. ', games: 'Next.js is your game engine - handling rendering, physics, and core systems so you can focus on gameplay. ', business: 'Next.js is your business framework - like a franchise model that provides proven systems and processes. ', nature: 'Next.js is like rich soil - providing nutrients and structure for your app to grow strong. ', cars: 'Next.js is like a car chassis - the frame and core systems are built, you add the engine and customize the features. ' }; return analogies[analogy] || analogies.architecture; } // Check if media reference should be included function shouldIncludeMediaReference(content, mediaInfluence) { const contentLower = content.toLowerCase(); const mediaLower = mediaInfluence.toLowerCase(); // Include if content relates to the media theme if (mediaLower.includes('matrix') && (contentLower.includes('system') || contentLower.includes('reality') || contentLower.includes('code'))) { return true; } if (mediaLower.includes('clean code') && (contentLower.includes('function') || contentLower.includes('naming') || contentLower.includes('refactor'))) { return true; } // Don't overuse references return Math.random() < 0.3; // 30% chance to include } // Get contextual media references function getContextualMediaReference(mediaInfluence, content) { const lowerMedia = mediaInfluence.toLowerCase(); const contentLower = content.toLowerCase(); if (lowerMedia.includes('matrix')) { if (contentLower.includes('authentication')) { return 'Like Neo entering the Matrix, authentication is your key to accessing the system.'; } if (contentLower.includes('database')) { return 'The database is your construct - the place where the rules of your digital reality are defined.'; } if (contentLower.includes('component')) { return 'Components are like the code rain in the Matrix - individual pieces that form the complete picture.'; } return 'You\'re not just writing code, you\'re architecting digital reality.'; } else if (lowerMedia.includes('clean code')) { if (contentLower.includes('naming')) { return 'As Uncle Bob teaches, good names reveal intent - your code should read like well-written prose.'; } if (contentLower.includes('function')) { return 'Remember Clean Code\'s principle: functions should do one thing and do it well.'; } return 'Following Clean Code principles here will make future you grateful.'; } return ''; } // Legacy function for backward compatibility (deprecated) export function wrapInInstructorPrompt(content, lessonName, stepName) { return createInstructorResponse(content, { lessonName, stepName, type: 'step_navigation' }); } //# sourceMappingURL=instructor.js.map