Implements 9 additional enforcement mechanisms across all priority levels: 🔒 HIGH PRIORITY - Architectural Enforcement: ✅ API Security Validator (inst_013/045) - scripts/check-api-security.js - Scans API endpoints for rate limiting - Validates authentication requirements - Detects sensitive runtime data exposure ✅ GitHub Repo Structure (inst_063_CONSOLIDATED) - scripts/check-github-repo-structure.js - Validates repository structure requirements - Ensures tractatus-framework remains implementation-focused ⚙️ MEDIUM PRIORITY - Process/Workflow: ✅ Human Approval Tracker (inst_005) - scripts/track-human-approvals.js - Logs approval requirements for major decisions - Tracks pending approvals ✅ Context Pressure Comprehensive (inst_019) - scripts/verify-context-pressure-comprehensive.js - Verifies all pressure factors included - Validates comprehensive context accounting 📋 LOW PRIORITY - Behavioral/Values: ✅ Behavioral Compliance Reminders (inst_047/049) - .claude/hooks/behavioral-compliance-reminder.js - Reminds never to dismiss user requests - Prompts to test user hypotheses first - Integrated into UserPromptSubmit hooks ✅ Dark Patterns Detector (inst_079) - scripts/check-dark-patterns.js - Scans UI code for manipulative patterns - Detects confirm shaming, hidden checkboxes, timed popups 📊 Enforcement Progress: - Wave 1: 11/39 (28%) - Wave 2: 18/39 (46%) - Wave 3: 22/39 (56%) - Wave 4: 31/39 (79%) - Total improvement: +20 instructions = +178% from baseline - Remaining gaps: 8/39 (21%) 🎯 Remaining 8 Gaps (requires runtime/process enforcement): - inst_039: Document processing verification - inst_043: Web form input validation (runtime) - inst_052: Scope adjustment authority tracking - inst_058: JSON/DB schema sync validation - inst_061: Hook approval pattern tracking - inst_072: Defense-in-depth credential layers - inst_080: Open source commitment (policy) - inst_081: Pluralism principle (foundational value) 🔄 Enhanced Hooks: - UserPromptSubmit now runs 3 hooks (triggers, all-commands, behavioral) - Added behavioral compliance reminders for session guidance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
73 lines
1.9 KiB
JavaScript
Executable file
73 lines
1.9 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
/**
|
|
* Dark Patterns Detector - Enforces inst_079
|
|
* Scans UI code for manipulative patterns
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
|
|
function checkFile(filePath) {
|
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
const violations = [];
|
|
const lines = content.split('\n');
|
|
|
|
const darkPatterns = [
|
|
{ pattern: /confirm\s*\?\s*:\s*cancel/i, msg: 'Confirm shaming (makes cancel feel negative)' },
|
|
{ pattern: /hidden|display:\s*none.*subscribe|newsletter/i, msg: 'Hidden subscription checkbox' },
|
|
{ pattern: /setTimeout.*modal|popup/i, msg: 'Timed popup (interrupts user)' },
|
|
{ pattern: /onbeforeunload.*subscribe|buy/i, msg: 'Exit popup manipulation' },
|
|
{ pattern: /disabled.*unsubscribe|cancel/i, msg: 'Disabled unsubscribe/cancel button' }
|
|
];
|
|
|
|
lines.forEach((line, idx) => {
|
|
darkPatterns.forEach(({ pattern, msg }) => {
|
|
if (pattern.test(line)) {
|
|
violations.push({
|
|
file: filePath,
|
|
line: idx + 1,
|
|
text: line.trim(),
|
|
message: msg
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
return violations;
|
|
}
|
|
|
|
function main() {
|
|
console.log('\n🎨 Dark Patterns Detection (inst_079)\n');
|
|
|
|
const files = process.argv.slice(2);
|
|
if (files.length === 0) {
|
|
console.log('✅ No files to scan\n');
|
|
process.exit(0);
|
|
}
|
|
|
|
const allViolations = [];
|
|
files.forEach(file => {
|
|
if (!fs.existsSync(file)) return;
|
|
if (!file.match(/\.(html|js|ts)$/)) return;
|
|
|
|
try {
|
|
const violations = checkFile(file);
|
|
allViolations.push(...violations);
|
|
} catch (err) {}
|
|
});
|
|
|
|
if (allViolations.length === 0) {
|
|
console.log('✅ No dark patterns detected\n');
|
|
process.exit(0);
|
|
}
|
|
|
|
console.log(`❌ Found ${allViolations.length} dark pattern(s):\n`);
|
|
allViolations.forEach(v => {
|
|
console.log(`🔴 ${v.file}:${v.line}`);
|
|
console.log(` ${v.message}`);
|
|
console.log(` ${v.text.substring(0, 60)}\n`);
|
|
});
|
|
|
|
process.exit(1);
|
|
}
|
|
|
|
main();
|