code: validate,tools,stream (2 files)

This commit is contained in:
2025-12-26 01:07:35 +00:00
parent 7aa1bb3af7
commit 674768837d
2 changed files with 73 additions and 0 deletions

View File

@@ -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

View File

@@ -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)
})