Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions skills/utils/anti-slop-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -49,6 +65,15 @@ function loadBannedPatterns() {
}
}

try {
fs.writeFileSync(cachePath, JSON.stringify({
timestamp: csvMtime,
patterns: patterns
}));
} catch (e) {
// Ignore cache write errors
}

return patterns;
}

Expand Down