import fs from 'fs'; import path from 'path'; import dotenv from 'dotenv'; import { createClient } from '@supabase/supabase-js'; dotenv.config({ path: '/path/to/file' }); const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; const serviceKey = process.env.SUPABASE_SERVICE_ROLE_KEY; if (!supabaseUrl || !serviceKey) throw new Error('Missing Supabase credentials'); const supabase = createClient(supabaseUrl, serviceKey, { auth: { autoRefreshToken: false, persistSession: false }, }); const slug = 'google-gemini'; const heroVideoUrl = 'https://www.youtube.com/watch?v=Uy6LcpyGj7w'; const verifiedDate = '2026-02-18'; const sourceLinks = { geminiWeb: 'https://gemini.google.com/', subscriptions: 'https://gemini.google/us/subscriptions/', oneAiPlans: 'https://one.google.com/about/ai-premium/', blogFeatureUpdate: 'https://blog.google/products/gemini/new-gemini-app-features-march-2025/', }; const overview = { hero_headline: 'Use Google Gemini to research, draft, and refine work in 20 minutes', hero_subhead: 'Start with one goal, add context, and iterate with short prompts to get usable output fast.', hero_time_estimate_minutes: 20, quick_verdict: { best_for: 'Fast drafting, summarizing, and planning with Google account access', not_for: 'Tasks that need guaranteed citations without manual verification', setup_time: '5 minutes', cost_to_start: 'Free', alternatives: ['ChatGPT', 'Claude'], }, metadata: { verified_on: verifiedDate, sources: Object.values(sourceLinks), }, }; const steps = [ { step_order: 1, title: 'Open Gemini and sign in', objective: 'Get to the chat interface and confirm you are on the correct account.', instructions_md: 'Go to gemini.google.com, sign in, and start a new chat.', copy_paste_input: null, expected_output: 'You see the Gemini chat box and model selector.', common_error: 'You are redirected or blocked by a workspace policy.', fix_text: 'Use a personal Google account or ask your admin to allow Gemini access.', setup_time_minutes: 2, }, { step_order: 2, title: 'State one clear outcome', objective: 'Anchor the session to a specific deliverable.', instructions_md: 'Ask for one output with format, length, and audience.', copy_paste_input: 'You are my assistant. Create a 150-word summary for a non-technical manager about: [topic]. Include 3 bullet takeaways and one risk.', expected_output: 'A short summary in the requested structure.', common_error: 'The reply is too broad or generic.', fix_text: 'Add audience, length, and required sections in the same prompt.', setup_time_minutes: 3, }, { step_order: 3, title: 'Add constraints and source expectations', objective: 'Reduce guesswork and make the response usable.', instructions_md: 'Set what to avoid and what evidence you want.', copy_paste_input: 'Revise this with plain language. Avoid jargon. If you make factual claims, list sources as links at the end.', expected_output: 'Cleaner draft with explicit source section.', common_error: 'No sources are listed.', fix_text: 'Ask again: "List only sources you actually used, as clickable URLs."', setup_time_minutes: 3, }, { step_order: 4, title: 'Upload a file for context', objective: 'Use your own material instead of starting from scratch.', instructions_md: 'Upload a PDF or doc and request a task tied to that file.', copy_paste_input: 'Read the uploaded file. Give me: 1) key points, 2) missing assumptions, 3) 5 follow-up questions for stakeholders.', expected_output: 'File-specific analysis with clear sections.', common_error: 'Gemini gives a shallow summary.', fix_text: 'Ask for line-item outputs and a fixed count per section.', setup_time_minutes: 4, }, { step_order: 5, title: 'Run one improvement pass', objective: 'Turn draft output into a final version.', instructions_md: 'Request a rewrite with strict tone and structure.', copy_paste_input: 'Rewrite the draft for an executive update. Keep it under 120 words. Use short sentences. End with one decision request.', expected_output: 'A concise final draft for your audience.', common_error: 'The rewrite drops important details.', fix_text: 'Tell Gemini which details are non-negotiable before rewriting.', setup_time_minutes: 3, }, { step_order: 6, title: 'Check facts before you publish', objective: 'Catch incorrect or outdated claims.', instructions_md: 'Verify claims against first-party sources before external use.', copy_paste_input: 'List every factual claim in your last answer as a checklist. For each claim, add a source URL or mark it "needs verification."', expected_output: 'A claim-by-claim verification checklist.', common_error: 'Some claims still lack sources.', fix_text: 'Remove or rewrite unsupported claims before using the output.', setup_time_minutes: 3, }, { step_order: 7, title: 'Save your prompt pattern', objective: 'Reuse what worked in future tasks.', instructions_md: 'Save your best prompt format in notes as a template with placeholders.', copy_paste_input: 'Template: Goal=[goal]. Audience=[audience]. Output format=[format]. Must include=[items]. Must avoid=[items].', expected_output: 'A reusable prompt template.', common_error: 'Template is too vague to reuse.', fix_text: 'Keep required sections and placeholders explicit.', setup_time_minutes: 2, }, ]; const recipes = [ { recipe_order: 1, name: 'Write a product description from raw notes', audience: 'Marketers and founders', summary: 'Turn bullet notes into a polished listing fast.', inputs_required: ['Product name', 'Target buyer', 'Top 3 benefits', 'Tone'], template_text: 'Create a product description for [product]. Target buyer: [buyer]. Benefits: [benefit 1], [benefit 2], [benefit 3]. Tone: [tone]. Output: 120 words plus 5 bullet highlights.', output_example: 'A short description plus bullet highlights ready for a product page.', time_saved_text: 'Saves 20-30 minutes per draft.', }, { recipe_order: 2, name: 'Analyze a long report into an action plan', audience: 'Ops and project leads', summary: 'Extract decisions, risks, and next steps from a dense file.', inputs_required: ['Uploaded report', 'Project goal', 'Deadline'], template_text: 'Read the uploaded report. Build a 30-day action plan for [goal] by [deadline]. Return: decisions needed this week, top 5 risks, and owners for each next step.', output_example: 'A time-bound action plan with owners and risk list.', time_saved_text: 'Saves 45-60 minutes of manual synthesis.', }, { recipe_order: 3, name: 'Review a code snippet for bugs and tests', audience: 'Developers', summary: 'Get a focused review instead of a generic explanation.', inputs_required: ['Code snippet', 'Language', 'Expected behavior'], template_text: 'Review this [language] snippet. Find logical bugs, edge cases, and missing tests. Output format: 1) issue list, 2) fixed code, 3) test cases with expected results. Code: [paste code].', output_example: 'Prioritized bug list, corrected snippet, and test checklist.', time_saved_text: 'Saves 15-25 minutes on first-pass review.', }, ]; const templates = [ { template_order: 1, title: 'Beginner: summarize a topic', category_tag: 'writing', tags: ['beginner', 'summary'], prompt_text: 'Explain [topic] to [audience] in 120 words. Use plain language and 3 bullet takeaways.', variables: { topic: 'string', audience: 'string' }, sample_input: 'topic=zero-trust security, audience=small business owner', sample_output: 'Zero-trust security means every access request is checked each time. It helps reduce damage if one account is compromised. Key takeaways: verify users often, limit access by role, monitor unusual activity.', difficulty: 'beginner', }, { template_order: 2, title: 'Beginner: rewrite for clarity', category_tag: 'writing', tags: ['beginner', 'editing'], prompt_text: 'Rewrite this text for clarity. Keep meaning the same. Limit to [word_count] words. Text: [text]', variables: { word_count: 'number', text: 'string' }, sample_input: 'word_count=90, text=We are leveraging cross-functional alignment to optimize synergy...', sample_output: 'We are aligning teams to remove delays and improve delivery speed. The plan sets clear owners and weekly checkpoints.', difficulty: 'beginner', }, { template_order: 3, title: 'Intermediate: compare options', category_tag: 'analysis', tags: ['intermediate', 'decision-making'], prompt_text: 'Compare [option_a] vs [option_b] for [use_case]. Return a table with cost, speed, risk, and maintenance.', variables: { option_a: 'string', option_b: 'string', use_case: 'string' }, sample_input: 'option_a=managed Postgres, option_b=self-hosted Postgres, use_case=SaaS app', sample_output: 'Table with tradeoffs: managed is faster to operate, self-hosted gives deeper control but higher ops load.', difficulty: 'intermediate', }, { template_order: 4, title: 'Intermediate: meeting brief', category_tag: 'productivity', tags: ['intermediate', 'meetings'], prompt_text: 'Create a meeting brief from these notes: [notes]. Output: agenda, decisions needed, and 5 questions to unblock progress.', variables: { notes: 'string' }, sample_input: 'notes=Q2 launch risks include delayed legal review and unclear owner for analytics.', sample_output: 'Agenda includes legal timeline, analytics ownership decision, and launch checklist review.', difficulty: 'intermediate', }, { template_order: 5, title: 'Intermediate: customer email response', category_tag: 'support', tags: ['intermediate', 'email'], prompt_text: 'Draft a customer email reply. Situation: [issue]. Tone: calm and direct. Include apology, fix, and next step.', variables: { issue: 'string' }, sample_input: 'issue=invoice charged twice', sample_output: 'Thanks for flagging this. You were charged twice, and we have issued a refund today. You will see it in 3-5 business days.', difficulty: 'intermediate', }, { template_order: 6, title: 'Advanced: SQL query review', category_tag: 'coding', tags: ['advanced', 'sql'], prompt_text: 'Review this SQL query for correctness and performance. Provide: issues, optimized query, and index suggestions. Query: [sql]', variables: { sql: 'string' }, sample_input: 'sql=SELECT * FROM orders WHERE DATE(created_at)=CURRENT_DATE;', sample_output: 'Issue: function on indexed column can block index use. Suggest range filter and index on created_at.', difficulty: 'advanced', }, { template_order: 7, title: 'Advanced: PR review checklist', category_tag: 'coding', tags: ['advanced', 'code-review'], prompt_text: 'Create a pull request review checklist for this diff summary: [summary]. Focus on regressions, security, and missing tests.', variables: { summary: 'string' }, sample_input: 'summary=adds OAuth callback handler and token refresh logic', sample_output: 'Checklist includes token validation, CSRF checks, error handling paths, and integration tests for refresh failures.', difficulty: 'advanced', }, { template_order: 8, title: 'Advanced: root cause analysis', category_tag: 'analysis', tags: ['advanced', 'incident-response'], prompt_text: 'Given this incident timeline [timeline], produce probable root causes, evidence needed, and a 24-hour remediation plan.', variables: { timeline: 'string' }, sample_input: 'timeline=09:10 error spike, 09:14 deploy complete, 09:20 DB saturation', sample_output: 'Likely causes include deployment query change and connection pool limit; remediation plan prioritizes rollback and query fix.', difficulty: 'advanced', }, { template_order: 9, title: 'Beginner: study plan builder', category_tag: 'learning', tags: ['beginner', 'planning'], prompt_text: 'Build a 2-week study plan for [topic] at [minutes_per_day] minutes per day. Include daily tasks and one checkpoint quiz each week.', variables: { topic: 'string', minutes_per_day: 'number' }, sample_input: 'topic=Python basics, minutes_per_day=30', sample_output: 'Day-by-day plan covering syntax, functions, loops, and mini exercises with weekly quizzes.', difficulty: 'beginner', }, { template_order: 10, title: 'Intermediate: convert notes to task list', category_tag: 'productivity', tags: ['intermediate', 'task-management'], prompt_text: 'Convert these notes into an actionable task list. For each task include owner, due date, and dependency. Notes: [notes]', variables: { notes: 'string' }, sample_input: 'notes=Finalize pricing page copy, legal sign-off pending, design handoff Friday', sample_output: 'Task list with owners for copy, legal review dependency, and design handoff milestone.', difficulty: 'intermediate', }, ]; const comparisons = [ { comparison_order: 1, alternative_name: 'ChatGPT', alternative_url: 'https://chatgpt.com/', when_to_choose_this: 'Choose Gemini when you want tight integration with Google services and one account across Google apps.', when_to_choose_alternative: 'Choose ChatGPT when your team already uses OpenAI workflows or custom GPT-based processes.', comparison_matrix: { best_at: { gemini: 'Google ecosystem tasks and fast drafting', alternative: 'Broad third-party ecosystem and custom GPT workflows', }, note: 'Both are strong for writing, analysis, and coding prompts.', }, }, { comparison_order: 2, alternative_name: 'Claude', alternative_url: 'https://claude.ai/', when_to_choose_this: 'Choose Gemini for users already working inside Google accounts and services.', when_to_choose_alternative: 'Choose Claude when you prefer its writing style or internal policy standards for long-form drafts.', comparison_matrix: { best_at: { gemini: 'Everyday productivity tied to Google tools', alternative: 'Long-form drafting and policy-heavy writing workflows', }, note: 'Test both on your real prompts before standardizing.', }, }, { comparison_order: 3, alternative_name: 'Perplexity', alternative_url: 'https://www.perplexity.ai/', when_to_choose_this: 'Choose Gemini for iterative drafting and planning inside a chat workflow.', when_to_choose_alternative: 'Choose Perplexity when you need citation-first web answers as the default output.', comparison_matrix: { best_at: { gemini: 'Drafting and refinement passes', alternative: 'Research with visible source citations', }, note: 'Use Gemini plus manual source checks for high-stakes facts.', }, }, ]; const faqs = [ { faq_order: 1, question: 'Is Google Gemini free to use?', answer_md: 'Yes. Gemini has a free tier. Paid plans exist for higher limits and extra features. Check current options on the Gemini subscriptions page because plans vary by region.', error_signature: null, quick_fix: 'If you only need basic chat and drafting, start on the free tier first.', }, { faq_order: 2, question: 'How long does setup take for a new user?', answer_md: 'Most users can start in about 5 minutes: sign in, open a new chat, and send the first prompt.', error_signature: null, quick_fix: 'Use a personal Google account if your workspace account blocks access.', }, { faq_order: 3, question: 'Why are my Gemini outputs too generic?', answer_md: 'Prompts that lack audience, format, and constraints usually produce generic text.', error_signature: 'Output is broad and non-specific', quick_fix: 'Add audience, exact format, length limit, and required sections in one prompt.', }, { faq_order: 4, question: 'Can Gemini read uploaded files?', answer_md: 'Yes, file upload support is available in Gemini app experiences. Ask for structured outputs tied to the uploaded file for better results.', error_signature: 'File summarized with low detail', quick_fix: 'Request fixed sections, counts, and follow-up questions instead of a single generic summary.', }, { faq_order: 5, question: 'How do I reduce factual errors?', answer_md: 'Treat model output as a draft. Ask Gemini to list factual claims and source links, then verify each claim on first-party sources before use.', error_signature: 'Unverified claims in output', quick_fix: 'Remove claims without sources or rewrite them as assumptions.', }, { faq_order: 6, question: 'Why can’t I access some Gemini features?', answer_md: 'Feature availability depends on plan, region, account type, and rollout timing.', error_signature: 'Feature missing from UI', quick_fix: 'Check account type, region support, and current plan details on official Gemini plan pages.', }, { faq_order: 7, question: 'Should I use one long prompt or several short prompts?', answer_md: 'Short iterative prompts usually work better. Start with the goal, then run one refinement pass per issue.', error_signature: null, quick_fix: 'Split work into draft, critique, and rewrite steps.', }, { faq_order: 8, question: 'Can Gemini help with coding tasks?', answer_md: 'Yes. It can explain code, suggest fixes, and draft tests. Always run and review code locally before merging.', error_signature: 'Code compiles but behavior is wrong', quick_fix: 'Ask for edge cases and test cases, then validate with your project test suite.', }, { faq_order: 9, question: 'What is the fastest way to improve prompt quality?', answer_md: 'Use a template with fixed fields: goal, audience, format, must-include items, and must-avoid items.', error_signature: null, quick_fix: 'Save your top prompt format and reuse it instead of writing from scratch each time.', }, ]; async function must(promise, label) { const { data, error, count } = await promise; if (error) throw new Error(`${label}: ${error.message}`); return { data, count }; } const report = { created_at: new Date().toISOString(), slug, selected_video: { url: heroVideoUrl, title: 'Master 85% of Google Gemini in 12 Minutes', channel: 'Jeff Su', upload_date: '2025-05-06', views_at_research_time: 718433, reason: 'Highest view count among beginner-oriented Gemini tutorials published within the last year during research.', research_method: 'yt-dlp metadata pull on 2026-02-18', }, sources_used: sourceLinks, }; async function run() { const toolRes = await must( supabase.from('tools').select('id,name,slug').eq('slug', slug).maybeSingle(), 'find tool by slug' ); const tool = toolRes.data; if (!tool) throw new Error(`Tool not found for slug=${slug}`); const toolId = tool.id; await must( supabase .from('tools') .update({ tutorial_enabled: true, tutorial_hero_video_url: heroVideoUrl, tutorial_last_reviewed_at: new Date().toISOString(), tutorial_schema_version: 1, }) .eq('id', toolId), 'update tools row' ); const cleanupTables = [ 'tool_tutorial_overviews', 'tool_tutorial_steps', 'tool_workflow_recipes', 'tool_prompt_templates', 'tool_comparisons', 'tool_tutorial_faqs', ]; for (const table of cleanupTables) { await must(supabase.from(table).delete().eq('tool_id', toolId), `cleanup ${table}`); } const overviewInsert = await must( supabase.from('tool_tutorial_overviews').insert({ tool_id: toolId, ...overview }).select('*').single(), 'insert overview' ); const stepsInsert = await must( supabase.from('tool_tutorial_steps').insert(steps.map((s) => ({ tool_id: toolId, ...s }))).select('*'), 'insert steps' ); const recipesInsert = await must( supabase.from('tool_workflow_recipes').insert(recipes.map((r) => ({ tool_id: toolId, ...r, inputs_required: r.inputs_required }))).select('*'), 'insert recipes' ); const templatesInsert = await must( supabase.from('tool_prompt_templates').insert(templates.map((t) => ({ tool_id: toolId, ...t }))).select('*'), 'insert templates' ); const comparisonsInsert = await must( supabase.from('tool_comparisons').insert(comparisons.map((c) => ({ tool_id: toolId, ...c }))).select('*'), 'insert comparisons' ); const faqsInsert = await must( supabase.from('tool_tutorial_faqs').insert(faqs.map((f) => ({ tool_id: toolId, ...f }))).select('*'), 'insert faqs' ); const tableCounts = {}; for (const table of cleanupTables) { const res = await must(supabase.from(table).select('*', { count: 'exact', head: true }).eq('tool_id', toolId), `count ${table}`); tableCounts[table] = res.count ?? 0; } report.tool = { id: toolId, name: tool.name, slug: tool.slug }; report.updated_tools_fields = { tutorial_enabled: true, tutorial_hero_video_url: heroVideoUrl, tutorial_schema_version: 1, }; report.created_records = { tool_tutorial_overviews: overviewInsert.data, tool_tutorial_steps: stepsInsert.data, tool_workflow_recipes: recipesInsert.data, tool_prompt_templates: templatesInsert.data, tool_comparisons: comparisonsInsert.data, tool_tutorial_faqs: faqsInsert.data, }; report.row_counts_for_tool = tableCounts; const lines = []; lines.push('# Google Gemini Tutorial Content Report'); lines.push(''); lines.push(`- Generated at: ${report.created_at}`); lines.push(`- Tool: ${tool.name} (id=${toolId}, slug=${tool.slug})`); lines.push(''); lines.push('## Hero Video Selected'); lines.push(`- URL: ${report.selected_video.url}`); lines.push(`- Title: ${report.selected_video.title}`); lines.push(`- Channel: ${report.selected_video.channel}`); lines.push(`- Upload date: ${report.selected_video.upload_date}`); lines.push(`- Views at research time: ${report.selected_video.views_at_research_time}`); lines.push(`- Selection reason: ${report.selected_video.reason}`); lines.push(''); lines.push('## Tools Row Update'); lines.push(`- tutorial_enabled: true`); lines.push(`- tutorial_hero_video_url: ${heroVideoUrl}`); lines.push(`- tutorial_schema_version: 1`); lines.push(''); lines.push('## Row Counts (for tool_id)'); for (const [table, count] of Object.entries(tableCounts)) { lines.push(`- ${table}: ${count}`); } lines.push(''); lines.push('## Created Records (JSON)'); lines.push('```json'); lines.push(JSON.stringify(report.created_records, null, 2)); lines.push('```'); lines.push(''); lines.push('## Source Links Used For Verification'); for (const [key, url] of Object.entries(sourceLinks)) { lines.push(`- ${key}: ${url}`); } fs.writeFileSync('/tmp/gemini-tutorial-report.md', lines.join('\n')); console.log(JSON.stringify({ success: true, tool_id: toolId, row_counts_for_tool: tableCounts }, null, 2)); } run().catch((err) => { console.error(err.message); process.exit(1); });