clean-hooks-tools.jsโข1.67 kB
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
console.log('๐งน CLEANING HOOKS TOOL REFERENCES');
console.log('=================================\n');
const hooksFiles = [
'teams/content-documentation/shadcn-ui-builder/hooks.json',
'teams/content-documentation/doc-writer/hooks.json',
'teams/software-engineering/refactor/hooks.json'
];
console.log(`๐ Processing ${hooksFiles.length} hooks files...\n`);
let processedCount = 0;
let errorCount = 0;
hooksFiles.forEach((filePath) => {
try {
const fullPath = path.resolve(filePath);
if (!fs.existsSync(fullPath)) {
console.log(`โ ๏ธ File not found: ${filePath}`);
errorCount++;
return;
}
// Read and parse JSON
const content = fs.readFileSync(fullPath, 'utf8');
const hooks = JSON.parse(content);
let modified = false;
// Remove PostToolUse hooks that reference tools
if (hooks.PostToolUse) {
delete hooks.PostToolUse;
modified = true;
}
if (modified) {
// Write back the cleaned hooks
fs.writeFileSync(fullPath, JSON.stringify(hooks, null, 2) + '\n', 'utf8');
processedCount++;
console.log(`โ
${filePath} - PostToolUse hooks removed`);
} else {
console.log(`โ
${filePath} - No tool references found`);
}
} catch (error) {
console.error(`โ Error processing ${filePath}:`, error.message);
errorCount++;
}
});
console.log(`\n๐ HOOKS CLEANUP COMPLETE!`);
console.log(`โ
Processed: ${processedCount} files`);
console.log(`โ Errors: ${errorCount} files`);
console.log(`๐ Total: ${hooksFiles.length} files`);