diff --git a/package.json b/package.json index fa532814..2fd9ec40 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,10 @@ "node": ">=18.0.0" }, "scripts": { - "build": "npm run build:patterns && tsc", + "build": "npm run build:patterns:if-needed && tsc", "build:patterns": "tsx scripts/buildEmbeddedPatterns.ts", + "build:patterns:if-needed": "node scripts/check-patterns.js || npm run build:patterns", + "build:patterns:force": "npm run build:patterns", "prepare": "npm run build", "test": "npm run test:unit", "test:watch": "vitest --config tests/configs/vitest.unit.config.ts", diff --git a/scripts/check-patterns.js b/scripts/check-patterns.js new file mode 100644 index 00000000..a20828ec --- /dev/null +++ b/scripts/check-patterns.js @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +/** + * Check if neural patterns need rebuilding + * Only rebuild if: + * 1. embeddedPatterns.ts doesn't exist + * 2. Pattern library source has changed + */ + +const fs = require('fs'); +const path = require('path'); + +const EMBEDDED_FILE = path.join(__dirname, '../src/neural/embeddedPatterns.ts'); +const PATTERN_LIBRARY = path.join(__dirname, '../src/neural/patternLibrary.ts'); + +// Check if embedded patterns exist +if (!fs.existsSync(EMBEDDED_FILE)) { + console.log('❌ Embedded patterns not found. Building...'); + process.exit(1); // Signal need to rebuild +} + +// Check if pattern library is newer than embedded patterns +const embeddedStats = fs.statSync(EMBEDDED_FILE); +const libraryStats = fs.statSync(PATTERN_LIBRARY); + +if (libraryStats.mtime > embeddedStats.mtime) { + console.log('🔄 Pattern library has changed. Rebuilding...'); + process.exit(1); // Signal need to rebuild +} + +console.log('✅ Embedded patterns are up-to-date. Skipping rebuild.'); +process.exit(0); // No rebuild needed \ No newline at end of file diff --git a/src/neural/embeddedPatterns.ts b/src/neural/embeddedPatterns.ts index 522ae8f6..30aea8dd 100644 --- a/src/neural/embeddedPatterns.ts +++ b/src/neural/embeddedPatterns.ts @@ -2,7 +2,7 @@ * 🧠 BRAINY EMBEDDED PATTERNS * * AUTO-GENERATED - DO NOT EDIT - * Generated: 2025-08-26T20:39:24.051Z + * Generated: 2025-08-27T16:37:10.556Z * Patterns: 220 * Coverage: 94-98% of all queries *