import dotenv from 'dotenv'; import { createClient } from '@supabase/supabase-js'; dotenv.config({ path: '.env' }); const BATCH_SIZE = 10; const SKIP_IDS = new Set([690]); const TOOL_FACTS = { 672: { category: 'llm_model', action: 'deploy open-source LLMs for reasoning, coding, and chat use cases' }, 673: { category: 'assistant_chat', action: 'draft, analyze, and automate everyday knowledge work with a general AI assistant' }, 674: { category: 'assistant_chat', action: 'run high-quality reasoning, writing, and coding tasks with a safety-focused AI assistant' }, 675: { category: 'llm_platform', action: 'prototype and test Gemini model prompts before building production features' }, 676: { category: 'agent_framework', action: 'orchestrate multiple AI agents with roles, memory, and shared goals' }, 677: { category: 'llm_platform', action: 'explore Google AI products, research, and model capabilities in one ecosystem' }, 678: { category: 'automation', action: 'automate multi-step workflows across apps with flexible no-code and self-hosted control' }, 680: { category: 'automation', action: 'build visual app integrations and business automations without writing code' }, 681: { category: 'agent_framework', action: 'experiment with autonomous goal-driven AI agents for complex task execution' }, 682: { category: 'automation', action: 'design AI-powered workflows for prompt operations, evaluation, and process automation' }, 683: { category: 'automation', action: 'connect cloud apps and automate repetitive operations with simple trigger-action flows' }, 684: { category: 'automation', action: 'set up simple personal and smart-home automations using if-this-then-that rules' }, 685: { category: 'automation', action: 'run private local smart-home automations with broad device integration' }, 686: { category: 'automation', action: 'automate business processes and approvals with a low-code workflow platform' }, 687: { category: 'agent_framework', action: 'build LLM chains and agent workflows with a drag-and-drop interface' }, 688: { category: 'agent_framework', action: 'build and deploy LLM applications with prompt, model, and workflow controls' }, 689: { category: 'agent_framework', action: 'create AI workforces and semantic workflows for business operations' }, 690: { category: 'assistant_chat', action: 'use Google Gemini for multimodal chat, reasoning, and productivity tasks' }, 691: { category: 'agent_framework', action: 'develop production LLM applications with chains, tools, and retrieval patterns' }, 692: { category: 'agent_framework', action: 'define structured task flows for multi-agent CrewAI systems' }, 693: { category: 'agent_framework', action: 'integrate AI orchestration into enterprise apps using Microsoft Semantic Kernel' }, 694: { category: 'agent_framework', action: 'add streaming chat and AI interactions to web apps with a frontend-first SDK' }, 695: { category: 'llm_model', action: 'run a strong open Meta model for local reasoning and coding workloads' }, 696: { category: 'research', action: 'research questions with cited answers from web sources in one interface' }, 697: { category: 'productivity', action: 'write, summarize, and organize workspace content directly inside Notion' }, 698: { category: 'video', action: 'generate cinematic AI video clips from text or image prompts' }, 699: { category: 'video', action: 'edit audio and video by editing transcript text with AI cleanup tools' }, 700: { category: 'image', action: 'generate high-quality AI artwork from text prompts with strong style control' }, 701: { category: 'coding', action: 'write and refactor code faster with inline AI suggestions in your IDE' }, 702: { category: 'coding', action: 'get AI code completion with privacy-focused deployment options for teams' }, 703: { category: 'coding', action: 'speed up coding tasks with AI-assisted generation and refactoring workflows' }, 771: { category: 'coding', action: 'build and refactor full codebases inside an AI-native editor' }, 772: { category: 'coding', action: 'prompt your way to full-stack web apps and deploy directly from the browser' }, 773: { category: 'coding', action: 'use an AI-first IDE to plan and execute multi-step coding tasks' }, 774: { category: 'coding', action: 'generate production-ready React and Next.js UI components from prompts' }, 775: { category: 'audio', action: 'create full songs with vocals and instrumentation from text prompts' }, 776: { category: 'audio', action: 'clone voices and generate natural speech for content and products' }, 777: { category: 'coding', action: 'generate full-stack app scaffolds from plain-language product ideas' }, 778: { category: 'coding', action: 'delegate coding tasks to an autonomous cloud development agent' }, 779: { category: 'video', action: 'create and edit AI video scenes from text and image inputs' }, 780: { category: 'image', action: 'generate AI images with reliable text rendering for creative assets' }, 781: { category: 'writing', action: 'produce on-brand marketing copy and campaign assets at scale' }, 782: { category: 'writing', action: 'automate go-to-market writing and outbound content workflows' }, 783: { category: 'meeting', action: 'transcribe meetings and generate searchable notes and summaries automatically' }, 784: { category: 'presentation', action: 'turn ideas and notes into polished presentations and docs quickly' }, 785: { category: 'video', action: 'create AI avatar videos for training, marketing, and internal communication' }, 786: { category: 'assistant_chat', action: 'build and chat with persona-based AI characters for entertainment and roleplay' }, 787: { category: 'ml_data', action: 'discover, share, and deploy open machine learning models and datasets' }, 788: { category: 'llm_platform', action: 'build enterprise NLP and RAG applications with production APIs' }, 789: { category: 'llm_model', action: 'use efficient open and commercial language models for production AI systems' }, 790: { category: 'writing', action: 'improve writing quality, tone, and clarity across emails and documents' }, 791: { category: 'coding', action: 'run an agentic coding assistant in the terminal for end-to-end code changes' }, 792: { category: 'agent_framework', action: 'run a persistent personal AI agent connected to messaging and tools' }, 793: { category: 'image', action: 'design social graphics, documents, and assets using built-in AI tools' }, 794: { category: 'presentation', action: 'build business presentations with automatic layout and design logic' }, 795: { category: 'meeting', action: 'capture meeting transcripts, summaries, and action items automatically' }, 796: { category: 'sales_support', action: 'analyze sales conversations to improve pipeline quality and coaching' }, 797: { category: 'sales_support', action: 'automate customer support conversations with an AI service agent' }, 798: { category: 'audio', action: 'compose royalty-friendly music tracks for videos, games, and media projects' }, 799: { category: 'writing', action: 'optimize articles for search rankings using data-driven SEO guidance' }, 800: { category: 'writing', action: 'plan content strategy and topic clusters for long-term organic growth' }, 801: { category: 'health', action: 'assess symptoms and triage potential care paths with an AI health assistant' }, 802: { category: 'video', action: 'record async video messages with automatic transcripts and summaries' }, 803: { category: 'meeting', action: 'capture voice notes and convert them into transcribed, summarized notes' }, 806: { category: 'writing', action: 'generate and schedule social content from trending topics in your niche' }, 807: { category: 'llm_model', action: 'use a large open model with multi-agent reasoning for advanced tasks' }, 808: { category: 'coding', action: 'delegate coding, refactoring, and code review tasks to an AI coding agent' }, 809: { category: 'assistant_chat', action: 'chat with a real-time assistant integrated with the X ecosystem' }, 810: { category: 'llm_model', action: 'run bilingual English-Chinese language models for production AI apps' }, 811: { category: 'llm_model', action: 'build long-context applications with a hybrid-architecture language model' }, 812: { category: 'llm_model', action: 'build with Alibaba open-weight multilingual models for reasoning and coding' }, 813: { category: 'llm_platform', action: 'deploy foundation models through AWS Bedrock with enterprise controls' }, 814: { category: 'llm_model', action: 'run an enterprise-ready open MoE model for data-heavy AI workloads' }, 815: { category: 'assistant_chat', action: 'use an empathetic personal AI assistant for everyday conversations' }, 816: { category: 'llm_model', action: 'deploy compact language models for efficient on-device AI applications' }, 817: { category: 'llm_model', action: 'build multimodal applications across text, image, audio, and video inputs' }, 818: { category: 'llm_model', action: 'work with open-source language models for lightweight text generation tasks' }, 819: { category: 'writing', action: 'generate compliant enterprise content with business-tuned language models' }, 820: { category: 'llm_model', action: 'build bilingual applications on China-focused GLM model families' }, 821: { category: 'coding', action: 'assign software engineering tasks to an autonomous AI developer' }, 822: { category: 'coding', action: 'pair program from the terminal with AI-assisted git-aware code edits' }, 823: { category: 'coding', action: 'embed an open-source AI coding assistant directly in your IDE' }, 824: { category: 'coding', action: 'use fast AI autocomplete and code chat across many IDEs for free' }, 825: { category: 'coding', action: 'accelerate AWS development with AI coding help and cloud-specific guidance' }, 826: { category: 'coding', action: 'ask codebase-aware questions and edits with repository graph context' }, 827: { category: 'image', action: 'generate production-quality images, assets, and textures for creative work' }, 828: { category: 'image', action: 'create and remix AI images on a mixed-image editing canvas' }, 829: { category: 'image', action: 'edit images with AI tools for cleanup, relighting, and background removal' }, 830: { category: 'image', action: 'iterate on AI images in real time from prompts and sketches' }, 831: { category: 'image', action: 'generate photorealistic images with a modern open model family' }, 832: { category: 'image', action: 'create prompt-faithful images with OpenAI’s latest image generation model' }, 833: { category: 'video', action: 'produce talking-avatar videos with translation and voice cloning' }, 834: { category: 'video', action: 'turn still photos into talking-head videos from scripts or audio' }, 835: { category: 'video', action: 'repurpose long videos into short-form social clips automatically' }, 836: { category: 'video', action: 'generate AI videos and 3D captures for immersive visual storytelling' }, 837: { category: 'video', action: 'generate longer-form AI videos with strong motion consistency' }, 838: { category: 'video', action: 'generate complete social videos from a single text brief' }, 839: { category: 'productivity', action: 'capture notes and retrieve context with AI-powered knowledge organization' }, 840: { category: 'writing', action: 'write SEO articles, ads, and marketing content with AI workflows' }, 841: { category: 'writing', action: 'generate low-cost marketing and business copy across common use cases' }, 842: { category: 'presentation', action: 'build narrative decks and story-driven presentations from prompts' }, 843: { category: 'productivity', action: 'manage projects with AI agents, docs, and task automation in one workspace' }, 844: { category: 'ml_data', action: 'automate enterprise machine learning from model building to monitoring' }, 845: { category: 'ml_data', action: 'train and deploy predictive and generative models on an open ML platform' }, 846: { category: 'ml_data', action: 'analyze business data with AI-assisted dashboards and natural language queries' }, 847: { category: 'ml_data', action: 'build no-code predictive models directly from spreadsheet-style data' }, 848: { category: 'audio', action: 'create realistic voiceovers with studio-style AI narration controls' }, 849: { category: 'audio', action: 'clone custom voices and generate real-time synthetic speech' }, 850: { category: 'audio', action: 'convert text, docs, and web pages into natural-sounding spoken audio' }, 851: { category: 'audio', action: 'remove background noise and generate cleaner meeting audio automatically' }, 852: { category: 'research', action: 'speed up literature review by finding and summarizing research papers' }, 853: { category: 'research', action: 'search academic papers with AI-assisted relevance and citation discovery' }, 854: { category: 'research', action: 'answer questions from peer-reviewed studies with evidence-linked summaries' }, 855: { category: 'research', action: 'map related papers visually to discover key research clusters quickly' }, 856: { category: 'presentation', action: 'turn AI research output into structured, shareable pages and articles' }, 857: { category: 'presentation', action: 'convert text ideas into diagrams and visuals for communication' }, 858: { category: 'coding', action: 'autocomplete multi-line code edits using Cursor’s context-aware Tab model' }, 859: { category: 'research', action: 'chat with uploaded sources and generate grounded research summaries' }, 860: { category: 'video', action: 'generate short high-quality videos from text prompts' }, 861: { category: 'video', action: 'create dance and motion-rich AI videos with multimodal control inputs' }, 862: { category: 'llm_model', action: 'run a cost-efficient multimodal reasoning model for advanced workloads' }, 863: { category: 'productivity', action: 'build no-code AI automations across Gmail, Docs, Drive, and Sheets' }, 864: { category: 'sales_support', action: 'deploy AI agents for CRM workflows in sales and service teams' }, 865: { category: 'video', action: 'generate navigable 3D worlds from text, images, and layout references' }, 866: { category: 'coding', action: 'navigate and modify large codebases with deep AI code understanding' }, 867: { category: 'coding', action: 'get very fast AI code completion with long-context repository support' }, 868: { category: 'coding', action: 'run an open-source terminal coding agent with bring-your-own-model control' }, 870: { category: 'methodology', action: 'run AI-assisted software delivery using a structured multi-agent development method' }, }; const CATEGORY_PROFILES = { assistant_chat: { minutes: 10, subhead: 'Start with one concrete outcome, provide context and constraints, then iterate prompts until the response is ready to use.', not_for: 'Work that requires guaranteed factual accuracy or formal compliance without human review.', setup_time: '5-10 minutes', alternatives: ['Claude', 'Google Gemini', 'Perplexity AI'], }, llm_model: { minutes: 20, subhead: 'Pick a deployment path first (API, hosted endpoint, or self-hosted), then test prompts on real tasks before scaling usage.', not_for: 'Teams that need turnkey no-code workflows without model operations or prompt tuning.', setup_time: '15-30 minutes', alternatives: ['Llama 3.3', 'Mistral AI', 'Alibaba Qwen'], }, llm_platform: { minutes: 15, subhead: 'Prototype prompts against a target model, evaluate output quality and latency, then wire successful prompts into your application flow.', not_for: 'Single-purpose tools where you do not need model testing, orchestration, or API-level control.', setup_time: '10-20 minutes', alternatives: ['Google AI Studio', 'OpenAI', 'Cohere'], }, automation: { minutes: 20, subhead: 'Connect your apps, define trigger-action steps, and validate edge cases with test data before enabling the workflow in production.', not_for: 'Heavy custom backend logic that requires full software development and custom infrastructure.', setup_time: '10-25 minutes', alternatives: ['Zapier', 'Make', 'n8n'], }, agent_framework: { minutes: 25, subhead: 'Define agent roles and tools, build a minimal task loop, and test on constrained scenarios before expanding scope.', not_for: 'Simple one-shot prompts where a single-model chat interface is sufficient.', setup_time: '15-30 minutes', alternatives: ['LangChain', 'CrewAI', 'Microsoft Semantic Kernel'], }, coding: { minutes: 15, subhead: 'Start with a small file or task, review generated changes carefully, then expand to multi-file refactors with tests in the loop.', not_for: 'Hands-off autonomous development without review, testing, and repository safeguards.', setup_time: '5-15 minutes', alternatives: ['Cursor', 'GitHub Copilot', 'Codeium'], }, image: { minutes: 10, subhead: 'Write a focused visual prompt, iterate style and composition in short cycles, then upscale or edit for final delivery.', not_for: 'Pixel-perfect brand systems that still require expert manual design and art direction.', setup_time: '5-10 minutes', alternatives: ['Midjourney', 'Ideogram', 'DALL-E 3'], }, video: { minutes: 20, subhead: 'Create a concise storyboard prompt, generate a first pass, then refine shots, timing, and voiceover for publish-ready output.', not_for: 'Long-form productions that require frame-level creative control and complex post-production pipelines.', setup_time: '10-20 minutes', alternatives: ['RunwayML', 'Pika', 'HeyGen'], }, audio: { minutes: 10, subhead: 'Choose a voice or music style first, generate a draft, then adjust pacing, tone, and output format for the target channel.', not_for: 'Projects requiring full legal rights clearance or studio-grade direction without manual review.', setup_time: '5-10 minutes', alternatives: ['ElevenLabs', 'Murf AI', 'Resemble AI'], }, writing: { minutes: 10, subhead: 'Define audience and channel, generate a structured draft, then revise tone and factual claims before publishing.', not_for: 'Unedited publishing of high-stakes legal, medical, or financial content.', setup_time: '5-10 minutes', alternatives: ['Jasper AI', 'Copy.ai', 'Writesonic'], }, meeting: { minutes: 10, subhead: 'Connect your meeting source, auto-capture transcript and summary, then review highlights and action items for accuracy.', not_for: 'Environments where recording consent, privacy controls, or compliance requirements are not satisfied.', setup_time: '5-10 minutes', alternatives: ['Otter.ai', 'Fireflies.ai', 'Krisp'], }, presentation: { minutes: 10, subhead: 'Start from a clear outline, let AI generate a first deck, then tighten narrative flow, visuals, and speaker notes.', not_for: 'Complex brand-heavy decks that require full manual design control from the start.', setup_time: '5-10 minutes', alternatives: ['Gamma', 'Tome', 'Beautiful.ai'], }, research: { minutes: 15, subhead: 'Frame a specific question, review citations and source quality, then synthesize findings into actionable conclusions.', not_for: 'Decisions that require exhaustive domain validation without checking primary sources.', setup_time: '5-15 minutes', alternatives: ['Perplexity AI', 'Elicit', 'Consensus'], }, ml_data: { minutes: 25, subhead: 'Prepare data first, run a baseline model or analysis, then iterate features and evaluation metrics before deployment.', not_for: 'Teams without reliable data governance, validation processes, or model monitoring practices.', setup_time: '20-30 minutes', alternatives: ['DataRobot', 'H2O.ai', 'Tableau AI'], }, sales_support: { minutes: 20, subhead: 'Connect CRM and conversation data, define success metrics, then deploy automations that are reviewed by your team.', not_for: 'Support or sales motions that require zero human oversight for sensitive customer decisions.', setup_time: '15-30 minutes', alternatives: ['Gong', 'Intercom Fin AI', 'Salesforce Agentforce'], }, health: { minutes: 10, subhead: 'Enter symptoms and context clearly, review suggested next steps, and confirm care decisions with licensed professionals.', not_for: 'Emergency diagnosis, treatment decisions, or replacing qualified medical care.', setup_time: '5-10 minutes', alternatives: ['WebMD Symptom Checker', 'Buoy Health', 'K Health'], }, productivity: { minutes: 10, subhead: 'Capture your working context first, then use AI to summarize, prioritize, and generate next actions you can execute immediately.', not_for: 'Teams expecting flawless automation without validating generated summaries and action plans.', setup_time: '5-10 minutes', alternatives: ['Notion AI', 'Mem.ai', 'Taskade AI'], }, methodology: { minutes: 30, subhead: 'Set project scope and constraints, assign agent roles by function, then run structured delivery loops with review checkpoints.', not_for: 'Very small one-off tasks where a lightweight prompt workflow is enough.', setup_time: '20-30 minutes', alternatives: ['CrewAI', 'LangChain', 'AutoGPT'], }, }; function titleCaseMinutes(minutes) { return Math.max(5, Math.min(30, Math.round(minutes / 5) * 5)); } function deriveCostToStart(pricingRaw) { const pricing = (pricingRaw || '').trim(); const lower = pricing.toLowerCase(); const priceMatch = pricing.match(/\$\s?\d+(?:\.\d+)?(?:\s*\/?\s*(?:mo|month|yr|year))?/i); if (!pricing) return 'Check vendor pricing'; if (/(open[- ]source|open source)/i.test(pricing)) { if (/free/i.test(lower) && priceMatch) return `Free (open-source) with paid hosted options from ${priceMatch[0].replace(/\s+/g, ' ')}`; if (/free/i.test(lower)) return 'Free (open-source) with optional paid hosted plans'; return 'Free (open-source) or paid managed hosting'; } if (/free/i.test(lower) && priceMatch) { return `Free tier available; paid plans from ${priceMatch[0].replace(/\s+/g, ' ')}`; } if (/free/i.test(lower)) { if (/trial/i.test(lower)) return 'Free trial available'; return 'Free or free tier available'; } if (priceMatch) { return `Starts at ${priceMatch[0].replace(/\s+/g, ' ')}`; } if (/(contact sales|custom|enterprise)/i.test(lower)) return 'Paid plans (contact sales)'; if (/pay[- ]?as[- ]?you[- ]?go|usage/i.test(lower)) return 'Usage-based pricing'; return pricing.split('.')[0].trim(); } function uniqueAlternatives(alts, toolName) { const norm = (toolName || '').toLowerCase(); return (alts || []).filter((alt) => !norm.includes(String(alt).toLowerCase())).slice(0, 3); } async function main() { const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; const serviceKey = process.env.SUPABASE_SERVICE_ROLE_KEY; if (!supabaseUrl || !serviceKey) { throw new Error('Missing NEXT_PUBLIC_SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY in .env'); } const supabase = createClient(supabaseUrl, serviceKey, { auth: { autoRefreshToken: false, persistSession: false }, }); const { data: tools, error: toolsError } = await supabase .from('tools') .select('id,name,description,pricing,url') .order('id', { ascending: true }); if (toolsError) throw new Error(`Failed fetching tools: ${toolsError.message}`); const { data: overviewRows, error: overviewError } = await supabase .from('tool_tutorial_overviews') .select('tool_id') .order('tool_id', { ascending: true }); if (overviewError) throw new Error(`Failed fetching overviews: ${overviewError.message}`); const overviewIds = new Set((overviewRows || []).map((r) => r.tool_id)); const missingOverview = tools.filter((t) => !overviewIds.has(t.id)); if (missingOverview.length > 0) { throw new Error(`Expected existing overview rows for all tools. Missing: ${missingOverview.map((t) => t.id).join(', ')}`); } const missingFacts = tools .filter((t) => !SKIP_IDS.has(t.id)) .filter((t) => !TOOL_FACTS[t.id]); if (missingFacts.length > 0) { throw new Error(`Missing TOOL_FACTS entries for tool IDs: ${missingFacts.map((t) => t.id).join(', ')}`); } const targets = tools.filter((t) => !SKIP_IDS.has(t.id)); const totalBatches = Math.ceil(targets.length / BATCH_SIZE); console.log(`Loaded ${tools.length} tools and ${overviewRows.length} overview rows.`); console.log(`Skipping tool IDs: ${Array.from(SKIP_IDS).join(', ')}`); console.log(`Updating ${targets.length} tools in ${totalBatches} batches of ${BATCH_SIZE}.`); let updatedCount = 0; let failedCount = 0; for (let i = 0; i < targets.length; i += BATCH_SIZE) { const batch = targets.slice(i, i + BATCH_SIZE); const batchNumber = Math.floor(i / BATCH_SIZE) + 1; console.log(`\\n[Batch ${batchNumber}/${totalBatches}] Processing ${batch.length} tools...`); for (const tool of batch) { const fact = TOOL_FACTS[tool.id]; const profile = CATEGORY_PROFILES[fact.category] || CATEGORY_PROFILES.assistant_chat; const minutes = titleCaseMinutes(profile.minutes); const hero_headline = `Use ${tool.name} to ${fact.action} in ${minutes} minutes`; const hero_subhead = profile.subhead; const hero_time_estimate_minutes = minutes; const quick_verdict = { best_for: `Teams that need to ${fact.action}.`, not_for: profile.not_for, setup_time: profile.setup_time, cost_to_start: deriveCostToStart(tool.pricing), alternatives: uniqueAlternatives(profile.alternatives, tool.name), }; const { error: updateError } = await supabase .from('tool_tutorial_overviews') .update({ hero_headline, hero_subhead, hero_time_estimate_minutes, quick_verdict, }) .eq('tool_id', tool.id); if (updateError) { failedCount += 1; console.error(` FAIL tool_id=${tool.id} ${tool.name}: ${updateError.message}`); } else { updatedCount += 1; console.log(` OK tool_id=${tool.id} ${tool.name}`); } } console.log(`[Batch ${batchNumber}/${totalBatches}] Completed. Running totals -> updated: ${updatedCount}, failed: ${failedCount}`); } console.log('\\nDone.'); console.log(`Updated rows: ${updatedCount}`); console.log(`Failed rows: ${failedCount}`); console.log(`Skipped rows: ${SKIP_IDS.size}`); if (failedCount > 0) { process.exitCode = 1; } } main().catch((error) => { console.error(`Fatal error: ${error.message}`); process.exit(1); });