import { readFileSync, existsSync } from "node:fs"; const requiredFiles = [ "src/features/history/pages/ProjectHistory.tsx", "src/app/routes.tsx", "src/shared/lib/navigation.tsx", "src/shared/contexts/ProjectContext.tsx", "src/shared/components/ProjectFlowRail.tsx", "src/features/projects/pages/Workspace.tsx", ]; const fail = (message) => { console.error(`ProjectBrain history center readiness: FAIL - ${message}`); process.exit(1); }; for (const file of requiredFiles) { if (!existsSync(file)) fail(`missing ${file}`); } const read = (file) => readFileSync(file, "utf8"); const page = read("src/features/history/pages/ProjectHistory.tsx"); const routes = read("src/app/routes.tsx"); const nav = read("src/shared/lib/navigation.tsx"); const context = read("src/shared/contexts/ProjectContext.tsx"); const historyCommands = read("src/shared/lib/projectHistoryCommands.ts"); const rail = read("src/shared/components/ProjectFlowRail.tsx"); const workspace = read("src/features/projects/pages/Workspace.tsx"); const routeRegistry = read("src/shared/lib/routeRegistry.ts"); const pkg = read("package.json"); if (!routes.includes('/projects/:projectId/history')) fail("history route is not registered"); if (!routes.includes('ProjectHistory')) fail("ProjectHistory page is not imported in routes"); if (!nav.includes('getPrimaryPathNavigationItems') || !nav.includes('projectRoutePath(projectId, key)')) fail("Project activity/history is missing from primary navigation"); if (!routeRegistry.includes('key: "activity"') || !routeRegistry.includes('segment: "history"')) fail("Project activity/history is missing from the canonical route registry"); if (!nav.includes('/history')) fail("history navigation path is missing"); if (!context.includes('deleteProjectHistoryEntry')) fail("context lacks history entry removal action"); if (!historyCommands.includes('hiddenHistoryEntryIds')) fail("project hidden history ids are not persisted"); if (!page.includes('downloadText')) fail("history page lacks download support"); if (!page.includes('navigator.clipboard')) fail("history page lacks copy/export support"); if (!page.includes('Uit geschiedenis verwijderen')) fail("history page lacks remove action"); if (!page.includes('getSnapshotsForProject') || !page.includes('getBuildsForProject')) fail("history page does not include snapshots and builds"); if (!page.includes('project.sourceLibrary') || !page.includes('project.mediaAssets')) fail("history page does not include source/media history"); if (!page.includes('project.starterReviewItems') || !page.includes('project.brainstorms')) fail("history page does not include review/brainstorm history"); if (!rail.includes('id: "history"')) fail("project flow rail lacks history step"); if (!nav.includes('/history')) fail("workspace navigation lacks history access"); if (!pkg.includes('audit:history-center')) fail("package scripts lack audit:history-center"); if (!pkg.includes('audit:source-library') || !pkg.includes('audit:guided-start')) fail("audit chain lost previous ProjectBrain gates"); console.log("ProjectBrain history center readiness: PASS");