const fs = require('fs'); const path = require('path'); const MAX_LINES = 400; // List of file patterns to ignore (optional, can be customized) const IGNORE_PATTERNS = [ /\.lock$/, // Lock files /\.min\.js$/, // Minified files /\.map$/, // Source maps /package-lock\.json$/, /bun\.lock$/, /tsconfig\.tsbuildinfo$/, /\.md$/, // Markdown documentation files /context\.md$/, // Context files for sub-agents /project-structure\.txt$/, // Generated project structure ]; function shouldIgnore(filePath) { return IGNORE_PATTERNS.some(pattern => pattern.test(filePath)); } const files = process.argv.slice(2); if (files.length === 0) { console.log('ℹ️ No files to check'); process.exit(0); } let hasError = false; files.forEach(file => { // Skip ignored patterns if (shouldIgnore(file)) { console.log(`⏭️ Skipping ${file} (ignored pattern)`); return; } // Check if file exists (it might have been deleted) if (!fs.existsSync(file)) { console.log(`⏭️ Skipping ${file} (file does not exist)`); return; } try { const content = fs.readFileSync(file, 'utf8'); const lines = content.split('\n').length; if (lines > MAX_LINES) { console.error(`❌ ${file} is too large (${lines} lines, max ${MAX_LINES}). AI agents will struggle. Please refactor!`); hasError = true; } else { console.log(`✅ ${file} (${lines} lines) - OK`); } } catch (err) { console.error(`⚠️ Error reading ${file}: ${err.message}`); // Don't fail on read errors, just warn } }); if (hasError) { process.exit(1); }