#!/usr/bin/env bun /** * Article Writing CLI * Spawns parallel AI agents to research and write articles */ import { handleInstallCommand } from '../../_common'; // Handle install/uninstall commands const SKILL_META = { name: 'write', description: 'Article writing skill that spawns parallel AI agents to research and write articles with image generation', version: '1.0.0', commands: `Use: write --help`, requiredEnvVars: [], }; if (await handleInstallCommand(SKILL_META, process.argv.slice(2))) { process.exit(0); } import { generateArticle, generateArticlesBatch } from './orchestrator'; // Parse command line arguments function parseArgs(): { command: string; topic?: string; topics?: string[]; style?: 'blog' | 'technical' | 'news' | 'academic' | 'casual'; length?: 'short' | 'medium' | 'long'; output?: string; image?: boolean; imageProvider?: 'openai' | 'google' | 'xai'; parallel?: number; filename?: string; } { const args = process.argv.slice(2); if (args[0] === '--help' || args[0] === '-h') args[0] = 'help'; const parsed: any = { command: args[0] || 'help' }; for (let i = 1; i < args.length; i++) { const arg = args[i]; if (arg.startsWith('--')) { const key = arg.replace(/^--/, ''); const value = args[i + 1]; if (key === 'image') { parsed.image = true; } else if (key === 'topics') { // Collect all topics until next flag const topicsList: string[] = []; i++; while (i < args.length && !args[i].startsWith('--')) { topicsList.push(args[i]); i++; } i--; // Adjust for the outer loop increment parsed.topics = topicsList; } else if (key === 'parallel') { parsed.parallel = parseInt(value, 10); i++; } else { parsed[key] = value; i++; } } } // Map 'image-provider' to 'imageProvider' if (parsed['image-provider']) { parsed.imageProvider = parsed['image-provider']; delete parsed['image-provider']; } return parsed; } // Display help information function showHelp(): void { console.log(` Article Writing CLI - Generate articles using parallel AI agents USAGE: bun run src/index.ts [options] COMMANDS: write Write a single article on a topic batch Write multiple articles in parallel help Show this help message WRITE OPTIONS: --topic Topic to write about (required) --style