Files
bitvid/scripts/check-hex.js
T
thePR0M3TH3ANandClaude Opus 4.8 c1ae810776 chore: remove TORCH subsystem (no longer used)
Removes the TORCH task-locking/scheduler-memory subsystem in full:
- delete torch/ (4900+ files), torch-config.json, and tracked .scheduler-memory/
- drop torch:* npm scripts and the torch-lock dependency; regenerate
  package-lock.json (only torch-lock removed)
- strip the dead "TORCH Memory Integration" / "Task Claiming Protocol (TORCH)"
  sections from AGENTS.md and CLAUDE.md (agent coordination is now PR-based) and
  the torch/TORCH.md doc-table row
- drop the stale `torch` ignore entries from check-hex / check-inline-styles /
  check-design-tokens

Build + touched lints pass. Note: views/dev/agent-dashboard.html still embeds
the external TORCH dashboard URL — left in place (separate dev-tools view).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-16 20:11:26 -04:00

95 lines
2.4 KiB
JavaScript
Executable File

#!/usr/bin/env node
import { spawnSync } from "node:child_process";
// Use PCRE2 lookbehind to avoid:
// 1. Matches preceded by a word character (e.g. `Issue#123`)
// 2. Matches preceded by `&` (e.g. HTML entities `&#039;`)
const SEARCH_PATTERN = '(?<!&|[\\w])#[0-9a-fA-F]{3,8}\\b';
// Allow-list tokens and vector logos so brand assets can keep their baked colors.
// These are translated to git pathspec exclusions.
const IGNORED_GLOBS = [
'css/tokens.css',
'**/*.svg',
'**/node_modules/**',
'.git/**',
'**/*.min.js',
'**/*.map',
'css/tailwind.generated.css',
'dist/**',
'build/**',
'vendor/**',
'js/utils/qrcode.js',
'**/dist/**',
'REMEDIATION_REPORT.md',
'CHANGELOG.md',
'scripts/daily-design-system-audit.mjs',
'config/instance-config.js',
'config/validate-config.js',
'js/embed.js',
'tests/unit/embed-accent.test.mjs',
'tests/visual/embed-layout.spec.ts',
'ai/**',
'**/*.ai',
'releases/**',
'bitvid-working-webtorrent/**',
'scripts/agent/**',
'docs/capacitor-native-app-plan.md',
'perf/**',
'test_logs/**',
'context/**',
'decisions/**',
'todo/**',
'test-audit/**',
'js/webtorrent.min.js',
'js/webtorrent.min.js.map',
];
const gitArgs = [
'grep',
'-n',
'-I', // Ignore binary files
'-P', // Enable PCRE2 for lookbehind support
SEARCH_PATTERN,
'--',
'.'
];
// Add exclusions
for (const glob of IGNORED_GLOBS) {
gitArgs.push(`:(exclude)${glob}`);
}
// We rely on 'git' being available and 'git grep' supporting -P.
// Typically available in most CI/dev environments.
// Increase maxBuffer to 10MB to prevent ENOBUFS on large minified files
const result = spawnSync('git', gitArgs, { encoding: 'utf8', maxBuffer: 10 * 1024 * 1024 });
if (result.error) {
console.error('Failed to execute git grep:', result.error.message);
process.exit(2);
}
// git grep exits with:
// 0 when matches are found (failure for us),
// 1 when no matches are found (success for us),
// 2+ on errors.
if (result.status === 0 && result.stdout.trim()) {
console.error('Hex colors detected outside tokens or SVG assets:');
console.error(result.stdout.trimEnd());
console.error('\nAllowed exceptions: tokens (css/tokens.css) and vector logos (*.svg).');
process.exit(1);
}
if (result.status && result.status !== 1) {
console.error('git grep reported an error while scanning for hex values.');
if (result.stderr) {
console.error(result.stderr.trimEnd());
}
process.exit(result.status);
}
process.exit(0);