script goes like so : ```js #!/usr/bin/env node import fs from 'fs/promises'; import path from 'path'; import https from 'https'; const REMOTE_URL = 'https://convex.link/convex_github_copilot_instructions'; const LOCAL_FILE_PATH = './.github/instructions/convex.instructions.md'; /** * Download file from URL */ function downloadFile(url) { return new Promise((resolve, reject) => { https.get(url, (response) => { // Handle redirects if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) { return downloadFile(response.headers.location).then(resolve).catch(reject); } if (response.statusCode !== 200) { reject(new Error(`HTTP ${response.statusCode}: ${response.statusMessage}`)); return; } let data = ''; response.setEncoding('utf8'); response.on('data', (chunk) => { data += chunk; }); response.on('end', () => { resolve(data); }); response.on('error', reject); }).on('error', reject); }); } /** * Ensure directory exists */ async function ensureDirectoryExists(filePath) { const dir = path.dirname(filePath); try { await fs.access(dir); } catch (error) { await fs.mkdir(dir, { recursive: true }); } } /** * Read local file content, return empty string if file doesn't exist */ async function readLocalFile(filePath) { try { return await fs.readFile(filePath, 'utf8'); } catch (error) { if (error.code === 'ENOENT') { return ''; } throw error; } } /** * Normalize content for comparison (trim whitespace, normalize line endings) */ function normalizeContent(content) { return content.trim().replace(/\r\n/g, '\n'); } /** * Main sync function */ async function syncInstructions() { console.log('🔄 Syncing Convex instructions...'); try { // Download remote content const remoteContent = await downloadFile(REMOTE_URL); // Read local content const localContent = await readLocalFile(LOCAL_FILE_PATH); // Normalize both contents for comparison const normalizedRemote = normalizeContent(remoteContent); const normalizedLocal = normalizeContent(localContent); // Compare contents if (normalizedRemote === normalizedLocal) { console.log('✅ Local instructions are up to date!'); process.exit(0); } // Contents differ, update local file console.log('📝 Updating local file...'); // Ensure directory exists await ensureDirectoryExists(LOCAL_FILE_PATH); // Write new content await fs.writeFile(LOCAL_FILE_PATH, remoteContent, 'utf8'); console.log('✅ Successfully updated local instructions!'); process.exit(0); } catch (error) { console.error('❌ Error syncing instructions:', error.message); process.exit(1); } } // Run the sync syncInstructions(); ```