/** * Validates that the TypeScript types match the expected server schema. * This script is meant to be run manually when the server schema changes. */ import { TaskType, Complexity, Harness, Provider, QualityGate, Outcome, RepoSizeCategory, } from '../src/types/events.js'; function validateEnum(name: string, enumObj: Record, expected: string[]): boolean { const values = Object.values(enumObj); const missing = expected.filter((v) => !values.includes(v)); const extra = values.filter((v) => !expected.includes(v)); if (missing.length > 0 || extra.length > 0) { console.error(`${name} mismatch:`); if (missing.length) console.error(` Missing: ${missing.join(', ')}`); if (extra.length) console.error(` Extra: ${extra.join(', ')}`); return false; } console.log(`${name}: OK (${values.length} values)`); return true; } let allValid = true; allValid = validateEnum('TaskType', TaskType, [ 'planning', 'implementation', 'code_review', 'testing', 'debugging', 'refactoring', 'documentation', 'configuration', 'security_audit', 'unknown', ]) && allValid; allValid = validateEnum('Complexity', Complexity, ['low', 'medium', 'high', 'critical']) && allValid; allValid = validateEnum('Harness', Harness, [ 'claude_code', 'opencode', 'kilo_code', 'aider', 'api_direct', 'ollama_local', 'custom', 'unknown', ]) && allValid; allValid = validateEnum('Provider', Provider, [ 'anthropic', 'openai', 'openrouter', 'ollama', 'google', 'mistral', 'custom', 'unknown', ]) && allValid; allValid = validateEnum('QualityGate', QualityGate, [ 'build', 'lint', 'test', 'coverage', 'typecheck', 'security', ]) && allValid; allValid = validateEnum('Outcome', Outcome, ['success', 'failure', 'partial', 'timeout']) && allValid; allValid = validateEnum('RepoSizeCategory', RepoSizeCategory, [ 'tiny', 'small', 'medium', 'large', 'huge', ]) && allValid; if (allValid) { console.log('\nAll enums validated successfully.'); } else { console.error('\nSchema validation failed.'); process.exit(1); }