// src/utils/hashUtils.ts
import { promises as fs } from 'fs';
import path from 'path';
import crypto from 'crypto';

export async function getToolsFileHash(): Promise<string> {
  const file = path.join(process.cwd(), 'src', 'data', 'tools.yaml');
  const raw = await fs.readFile(file, 'utf8');
  return crypto.createHash('sha256').update(raw).digest('hex');
}

export function getToolsFileHashSync(): string | null {
  try {
    const file = path.join(process.cwd(), 'src', 'data', 'tools.yaml');
    const raw = require('fs').readFileSync(file, 'utf8');
    return crypto.createHash('sha256').update(raw).digest('hex');
  } catch {
    return null;
  }
}