Code-first video & image, rendered natively on WebGPU.
feat(cli): QA on local renders, load the project's .env
okanasl515b3f32416d
diff --git a/.changeset/local-render-preview.md b/.changeset/local-render-preview.mdindex 357d2226..f6b053de 100644--- a/.changeset/local-render-preview.md+++ b/.changeset/local-render-preview.md@@ -2,4 +2,4 @@"framefields": minor----`framefields render <name>` renders a named render on this machine and `framefields preview <name>` plays it in the browser, reading the same `framefields.json` render as `--cloud`, so a render writes the same file wherever it runs. Both load the module with the project's own tsx and framefields. A local render first downloads pinned assets that are missing; the preview streams them from their bucket instead (redirecting the page to the remote's `publicUrl` or a signed URL, and mixing the soundtrack over HTTP), so an agent in a cloud sandbox previews footage without downloading it. `init`'s `render` and `preview` scripts now call the CLI.+`framefields render <name>` renders a named render on this machine and `framefields preview <name>` plays it in the browser, reading the same `framefields.json` render as `--cloud`, so a render writes the same file wherever it runs. Both load the module with the project's own tsx and framefields. A local render first downloads pinned assets that are missing; the preview streams them from their bucket instead (redirecting the page to the remote's `publicUrl` or a signed URL, and mixing the soundtrack over HTTP), so an agent in a cloud sandbox previews footage without downloading it. `init`'s `render` and `preview` scripts now call the CLI. A local render runs QA (`qa: true`), prints the report and exits non-zero when QA fails. Every `framefields` command loads the project's `.env` (variables already set win), so `render --cloud` and the storage commands find `FRAMEFIELDS_API_KEY` and remote keys kept there.diff --git a/packages/framefields/src/cli.ts b/packages/framefields/src/cli.tsindex 24c52dcc..6d83ff72 100644--- a/packages/framefields/src/cli.ts+++ b/packages/framefields/src/cli.ts@@ -13,7 +13,7 @@* npx framefields render <name> --cloud render on api.framefields.dev* npx framefields preview <name> play it in the browser*/-import { readFileSync } from "node:fs";+import { existsSync, readFileSync } from "node:fs";import { join, relative, resolve } from "node:path";import { fileURLToPath } from "node:url";import { parseArgs } from "node:util";@@ -191,6 +191,9 @@ async function main(argv: string[]): Promise<number> {return command || values.help ? 0 : 1;}const cwd = process.cwd();+ // The project's settings (FRAMEFIELDS_API_KEY, storage keys), as its own+ // scripts load them; variables already set win.+ if (existsSync(join(cwd, ".env"))) process.loadEnvFile(join(cwd, ".env"));const log = (line: string) => process.stdout.write(`${line}\n`);if (command === "api") {const catalog = JSON.parse(diff --git a/packages/framefields/src/cli/local-worker.ts b/packages/framefields/src/cli/local-worker.tsindex 3a7382c0..ec735003 100644--- a/packages/framefields/src/cli/local-worker.ts+++ b/packages/framefields/src/cli/local-worker.ts@@ -9,6 +9,7 @@* decoders.*/import { pathToFileURL } from "node:url";+import type { formatQaReport } from "../index.js";import type { startPreview } from "../preview/index.js";import { pickComposition } from "./pick-composition.js";@@ -30,7 +31,7 @@ export interface LocalJob {}export type LocalResult =- | { ok: true; filePath?: string }+ | { ok: true; filePath?: string; qaPassed?: boolean }| { ok: false; message: string };async function run(job: LocalJob): Promise<LocalResult> {@@ -55,9 +56,21 @@ async function run(job: LocalJob): Promise<LocalResult> {outputPath: job.outputPath,...(job.codec && { codec: job.codec }),...(job.quality && { quality: job.quality }),+ // Dropped, black or frozen frames, loudness, clipping, truncated animations.+ qa: true,});await result.cleanup?.();- return { ok: true, filePath: result.filePath };+ if (result.qa) {+ const engine = (await import(job.engine)) as {+ formatQaReport: typeof formatQaReport;+ };+ process.stdout.write(`${engine.formatQaReport(result.qa)}\n`);+ }+ return {+ ok: true,+ filePath: result.filePath,+ ...(result.qa && { qaPassed: result.qa.passed }),+ };}process.once("message", (job: LocalJob) => {diff --git a/packages/framefields/src/cli/local.ts b/packages/framefields/src/cli/local.tsindex 1f31c282..cded1dcc 100644--- a/packages/framefields/src/cli/local.ts+++ b/packages/framefields/src/cli/local.ts@@ -75,7 +75,8 @@ export async function runLocal(}if (result.filePath)log(`Rendered ${path.relative(cwd, result.filePath) || result.filePath}`);- return 0;+ // The video is written either way; failed QA fails the command.+ return result.qaPassed === false ? 1 : 0;}/** The framefields the film imports, resolved from its module. */