#!/usr/bin/env node
import assert from 'assert';
import fs from 'fs';

const compileRoute = fs.readFileSync('./src/server/routes/compile.js', 'utf-8');
const projectRoute = fs.readFileSync('./src/server/routes/project.js', 'utf-8');

assert(
  compileRoute.includes("if (req.body?.file_path === 'all')") &&
  compileRoute.includes('await server.projectContext.scan();'),
  'validate route should rescan projectContext before validating the full project'
);

assert(
  projectRoute.includes("app.get('/api/metadata/extract'") &&
  projectRoute.includes('await server.projectContext.scan();'),
  'metadata extract route should rescan projectContext before extracting metadata'
);

console.log('\n── Project Route Refresh Regression ──');
console.log('PASS test-project-route-refresh.js');
