// Auto-format edited files with prettier
const { execSync } = require('child_process');
let data = '';
process.stdin.on('data', chunk => data += chunk);
process.stdin.on('end', () => {
  try {
    const input = JSON.parse(data);
    const filePath = input.tool_response?.filePath || input.tool_input?.file_path || '';
    if (filePath) {
      execSync(`npx prettier --write "${filePath}" --ignore-unknown`, { stdio: 'ignore', timeout: 10000 });
    }
  } catch {}
});
