From 6aaac1067ec6071bf8b907545546da381979eeaa Mon Sep 17 00:00:00 2001 From: Jules Date: Sat, 18 Jul 2026 08:05:13 +0000 Subject: [PATCH] feat: Implement persistent JSON caching for anti-slop audits --- skills/utils/anti-slop-checker.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/skills/utils/anti-slop-checker.js b/skills/utils/anti-slop-checker.js index d895332..64f8c2e 100755 --- a/skills/utils/anti-slop-checker.js +++ b/skills/utils/anti-slop-checker.js @@ -9,16 +9,32 @@ const fs = require('fs'); const path = require('path'); const { execSync } = require('child_process'); +const os = require('os'); // Load banned patterns from CSV function loadBannedPatterns() { const csvPath = path.join(__dirname, '../design-skill/references/ai-slop-banned.csv'); + const cachePath = path.join(os.tmpdir(), 'anti-slop-cache.json'); if (!fs.existsSync(csvPath)) { console.error('❌ ai-slop-banned.csv not found at:', csvPath); process.exit(1); } + const csvStats = fs.statSync(csvPath); + const csvMtime = csvStats.mtimeMs; + + if (fs.existsSync(cachePath)) { + try { + const cacheData = JSON.parse(fs.readFileSync(cachePath, 'utf8')); + if (cacheData.timestamp >= csvMtime) { + return cacheData.patterns; + } + } catch (e) { + // Ignore cache read errors + } + } + const csvContent = fs.readFileSync(csvPath, 'utf8'); const lines = csvContent.split('\n').slice(1); // Skip header @@ -49,6 +65,15 @@ function loadBannedPatterns() { } } + try { + fs.writeFileSync(cachePath, JSON.stringify({ + timestamp: csvMtime, + patterns: patterns + })); + } catch (e) { + // Ignore cache write errors + } + return patterns; }