UNPKG

wordlift-cli

Version:

WordLift CLI - A customized CLI for WordLift SEO workflows with agent memory system and smart project directory detection

91 lines (74 loc) 3.46 kB
#!/usr/bin/env node /** * WordLift CLI - Standalone version with embedded WordLift branding * @license Apache-2.0 */ const { spawn } = require('child_process'); const path = require('path'); const fs = require('fs'); const os = require('os'); // Get the directory where this script is located const scriptDir = path.dirname(__filename); const projectRoot = path.dirname(scriptDir); // Set up environment variables process.env.GEMINI_CONFIG_DIR = path.join(projectRoot, '.gemini'); // Function to patch Gemini CLI with WordLift branding function patchGeminiCLI() { const tempDir = os.tmpdir(); const patchedDir = path.join(tempDir, 'wordlift-gemini-cli'); if (!fs.existsSync(patchedDir)) { fs.mkdirSync(patchedDir, { recursive: true }); // Create a patched version of the AsciiArt.js const patchedAsciiArt = `/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ export const shortAsciiLogo = \` ██ ██ ██████ ██████ ██████ ██ ██ ███████ ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █ ██ ██ ██ ██████ ██ ██ ██ ██ █████ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ███ ██████ ██ ██ ██████ ███████ ██ ██ ██ 🚀 WordLift CLI - Your SEO Assistant \`; export const longAsciiLogo = \` ██ ██ ██████ ██████ ██████ ██ ██ ███████ ████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █ ██ ██ ██ ██████ ██ ██ ██ ██ █████ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ███ ██████ ██ ██ ██████ ███████ ██ ██ ██ 🚀 WordLift CLI - Your SEO Assistant \`; //# sourceMappingURL=AsciiArt.js.map`; fs.writeFileSync(path.join(patchedDir, 'AsciiArt.js'), patchedAsciiArt); } return patchedDir; } // Prepare arguments - pass through all command line arguments const args = process.argv.slice(2); // Use npx to run Gemini CLI but with environment variable to override the ASCII art const patchedDir = patchGeminiCLI(); process.env.NODE_PATH = patchedDir + ':' + (process.env.NODE_PATH || ''); // Spawn the Gemini CLI with WordLift configuration const geminiProcess = spawn('npx', ['@google/gemini-cli', ...args], { stdio: 'inherit', cwd: projectRoot, env: { ...process.env, GEMINI_CONFIG_DIR: path.join(projectRoot, '.gemini'), WORDLIFT_BRANDING: 'true' } }); geminiProcess.on('error', (error) => { if (error.code === 'ENOENT') { console.error('❌ Failed to start WordLift CLI. Please ensure Node.js is installed.'); console.error(' You can also try: npm install -g @google/gemini-cli'); } else { console.error('❌ Error running WordLift CLI:', error.message); } process.exit(1); }); geminiProcess.on('close', (code) => { process.exit(code); });