diff --git a/packages/stream_cast/seed/scripts/audience_pulse.lua b/packages/stream_cast/seed/scripts/audience_pulse.lua new file mode 100644 index 000000000..3bec8cbf1 --- /dev/null +++ b/packages/stream_cast/seed/scripts/audience_pulse.lua @@ -0,0 +1,24 @@ +local M = {} + +function M.score(metrics) + local messages = metrics.messagesPerMinute or 0 + local reactions = metrics.reactionsPerMinute or 0 + local viewers = metrics.viewers or 1 + + local raw = (messages * 0.6) + (reactions * 0.4) + local score = (raw / viewers) * 100 + + local tier = "steady" + if score >= 80 then + tier = "surging" + elseif score <= 30 then + tier = "cooling" + end + + return { + score = score, + tier = tier + } +end + +return M diff --git a/tools/validate-codegen-export.ts b/tools/validate-codegen-export.ts new file mode 100644 index 000000000..fe49177e6 --- /dev/null +++ b/tools/validate-codegen-export.ts @@ -0,0 +1,49 @@ +#!/usr/bin/env tsx + +import { mkdir, writeFile } from 'node:fs/promises' +import { fileURLToPath } from 'node:url' + +import JSZip from 'jszip' + +import { generateCodegenZip } from '../frontends/nextjs/src/lib/codegen/generate-codegen-zip' + +const spec = { + projectName: 'neon-arcade-export', + packageId: 'arcade_lobby', + runtime: 'desktop', + tone: 'neon', + brief: 'Validates the Codegen Studio bundle outputs.', +} + +const rootDir = spec.projectName.replace(/[^a-z0-9-]/gi, '-').toLowerCase() +const outputDir = fileURLToPath(new URL('../.tmp', import.meta.url)) +const outputFile = `${outputDir}/${spec.projectName}.zip` + +const assertZipContains = async (zipBuffer: Buffer) => { + const zip = await JSZip.loadAsync(zipBuffer) + const paths = [ + `${rootDir}/README.md`, + `${rootDir}/src/app/page.tsx`, + `${rootDir}/cli/main.cpp`, + `${rootDir}/spec.json`, + ] + + for (const entry of paths) { + if (!zip.file(entry)) { + throw new Error(`Missing expected entry ${entry}`) + } + } +} + +const run = async () => { + await mkdir(outputDir, { recursive: true }) + const { zipBuffer } = await generateCodegenZip(spec) + await assertZipContains(zipBuffer) + await writeFile(outputFile, zipBuffer) + console.log('Codegen export validated at', outputFile) +} + +run().catch((error) => { + console.error('Codegen export validation failed:', error) + process.exit(1) +})