| 72 | } |
| 73 | |
| 74 | function loadData(): CodemodeData { |
| 75 | if (cachedData) return cachedData; |
| 76 | |
| 77 | if (!existsSync(DATA_PATH)) { |
| 78 | throw new Error(`Data file not found: ${DATA_PATH}\nRun 'pnpm transform:codemode' first.`); |
| 79 | } |
| 80 | |
| 81 | console.log('Loading codemode data...'); |
| 82 | const raw = readFileSync(DATA_PATH, 'utf-8'); |
| 83 | cachedData = JSON.parse(raw) as CodemodeData; |
| 84 | console.log( |
| 85 | `Loaded: ${cachedData.repos.length} repos, ${cachedData.users.length} users, ${cachedData.issues.length} issues, ${cachedData.pulls.length} pulls`, |
| 86 | ); |
| 87 | return cachedData; |
| 88 | } |
| 89 | |
| 90 | function truncateOutput(output: string): string { |
| 91 | if (output.length <= MAX_OUTPUT_CHARS) return output; |