Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(cli): collapse startup lint output to a one-line summary (#4052)
Miguel Ángel096459e76d74
diff --git a/packages/cli/src/commands/preview.ts b/packages/cli/src/commands/preview.tsindex 5203d7eead..f1f3858cff 100644--- a/packages/cli/src/commands/preview.ts+++ b/packages/cli/src/commands/preview.ts@@ -28,6 +28,10 @@ export const examples: Example[] = ["Disable auto-proxying of browser-hostile video codecs (HEVC, ProRes, AV1)","hyperframes preview --no-proxy",],+ [+ "Show full lint findings on startup instead of the summary line",+ "hyperframes preview --lint-verbose",+ ],];import {existsSync,@@ -54,7 +58,7 @@ import {validateRemoteDebuggingPortDeps,} from "../utils/openBrowser.js";import { lintProject } from "../utils/lintProject.js";-import { formatLintFindings } from "../utils/lintFormat.js";+import { formatLintStartupMessage } from "../utils/lintFormat.js";import {activeServerOnPort,findPortAndServe,@@ -177,6 +181,11 @@ export default defineCommand({description: "Kill all active preview servers and exit",default: false,},+ "lint-verbose": {+ type: "boolean",+ description: "Show full lint findings on startup (default: a one-line summary)",+ default: false,+ },open: {type: "boolean",default: true,@@ -420,7 +429,12 @@ export default defineCommand({const lintResult = await lintProject(dir);if (!args.json && (lintResult.totalErrors > 0 || lintResult.totalWarnings > 0)) {console.log();- for (const line of formatLintFindings(lintResult)) console.log(line);+ const verbose = Boolean(args["lint-verbose"]);+ for (const line of formatLintStartupMessage(+ lintResult,+ verbose ? { kind: "verbose" } : { kind: "summary", pointer: "studio" },+ ))+ console.log(line);console.log();}diff --git a/packages/cli/src/commands/publish.test.ts b/packages/cli/src/commands/publish.test.tsindex b26fa1b5b4..c8eb1d5e6e 100644--- a/packages/cli/src/commands/publish.test.ts+++ b/packages/cli/src/commands/publish.test.ts@@ -90,6 +90,13 @@ describe("publish default-entry preflight", () => {expect(output).not.toContain("hyperframes publish <project>/compositions");expect(output).toContain("publish accepts project directories, not individual HTML files");});++ it("prints the full finding on a default-entry-mismatch abort even without --lint-verbose", async () => {+ const output = await runEntryMismatch("compositions/brand/index.html");++ expect(output).toContain("blank_root_with_standalone_composition");+ expect(output).not.toContain("run with --lint-verbose for full output");+ });});describe("publish visibility messaging", () => {diff --git a/packages/cli/src/commands/publish.ts b/packages/cli/src/commands/publish.tsindex 3947544392..8a18116f5d 100644--- a/packages/cli/src/commands/publish.ts+++ b/packages/cli/src/commands/publish.ts@@ -11,7 +11,7 @@ import {hasDefinitiveEntryMismatch,lintProject,} from "../utils/lintProject.js";-import { formatLintFindings } from "../utils/lintFormat.js";+import { formatLintStartupMessage } from "../utils/lintFormat.js";import {buildPublishFileMap,publishProjectArchive,@@ -35,6 +35,7 @@ export const examples: Example[] = [["Publish to a shared team space", "hyperframes publish --space <space-id>"],["Skip the consent prompt (scripts)", "hyperframes publish --yes"],["Skip baking H.264 proxies for browser-hostile video codecs", "hyperframes publish --no-proxy"],+ ["Show full lint findings instead of the summary line", "hyperframes publish --lint-verbose"],];/** Extract a project id from a published URL (with or without scheme, query, or hash) or accept a bare id. */@@ -84,6 +85,11 @@ export default defineCommand({description:"Bake H.264 proxies for browser-hostile video codecs (e.g. HEVC) into the published archive. Default: on, unless disabled via hyperframes.json media.autoProxy. Pass --no-proxy to skip.",},+ "lint-verbose": {+ type: "boolean",+ description: "Show full lint findings before publishing (default: a one-line summary)",+ default: false,+ },},async run({ args }) {const rawArg = args.dir;@@ -91,12 +97,18 @@ export default defineCommand({const indexPath = join(dir, "index.html");if (existsSync(indexPath)) {const lintResult = await lintProject(dir);+ const definitiveEntryMismatch = hasDefinitiveEntryMismatch(lintResult);if (lintResult.totalErrors > 0 || lintResult.totalWarnings > 0) {console.log();- for (const line of formatLintFindings(lintResult)) console.log(line);+ const verbose = Boolean(args["lint-verbose"]) || definitiveEntryMismatch;+ for (const line of formatLintStartupMessage(+ lintResult,+ verbose ? { kind: "verbose" } : { kind: "summary" },+ ))+ console.log(line);console.log();}- if (hasDefinitiveEntryMismatch(lintResult)) {+ if (definitiveEntryMismatch) {const candidate = definitiveEntryMismatchComposition(lintResult);console.log(c.error(" Aborting publish because the default index.html entry is blank."));if (candidate && posix.basename(candidate) === "index.html") {diff --git a/packages/cli/src/commands/render.test.ts b/packages/cli/src/commands/render.test.tsindex c0607b1e71..5eec74b758 100644--- a/packages/cli/src/commands/render.test.ts+++ b/packages/cli/src/commands/render.test.ts@@ -321,6 +321,113 @@ describe("renderLocal browser GPU config", () => {).rejects.toMatchObject({ name: "CliRuntimeError" });});+ it("prints the full finding on a default-entry-mismatch abort even without --lint-verbose", async () => {+ const lintResult = {+ results: [+ {+ file: "index.html",+ contentHash: "abc",+ result: {+ ok: false,+ errorCount: 1,+ warningCount: 0,+ infoCount: 0,+ findings: [+ {+ code: "blank_root_with_standalone_composition",+ severity: "error" as const,+ message: "The default index.html composition has no renderable content",+ fixHint: "Move the authored composition into index.html",+ },+ ],+ },+ },+ ],+ totalErrors: 1,+ totalWarnings: 0,+ totalInfos: 0,+ };+ const logSpy = vi.spyOn(console, "log").mockImplementation(() => {});++ await expect(+ runRenderLint(+ {+ project: { dir: "/tmp/project" },+ entryFile: undefined,+ renderTarget: "/tmp/project/index.html",+ strictErrors: false,+ strictAll: false,+ effectiveQuiet: false,+ lintVerbose: false,+ } as never,+ async () => lintResult,+ ),+ ).rejects.toMatchObject({ name: "CliRuntimeError" });++ const output = logSpy.mock.calls.map((c) => c[0]).join("\n");+ expect(output).toContain("blank_root_with_standalone_composition");+ expect(output).toContain("The default index.html composition has no renderable content");+ logSpy.mockRestore();+ });++ it("prints a one-line summary by default, and full findings when lintVerbose is set", async () => {+ const lintResult = {+ results: [+ {+ file: "index.html",+ contentHash: "abc",+ result: {+ ok: true,+ errorCount: 0,+ warningCount: 1,+ infoCount: 0,+ findings: [+ { code: "some_warning", severity: "warning" as const, message: "a warning" },+ ],+ },+ },+ ],+ totalErrors: 0,+ totalWarnings: 1,+ totalInfos: 0,+ };+ const logSpy = vi.spyOn(console, "log").mockImplementation(() => {});++ await runRenderLint(+ {+ project: { dir: "/tmp/project" },+ entryFile: undefined,+ renderTarget: "/tmp/project/index.html",+ strictErrors: false,+ strictAll: false,+ effectiveQuiet: false,+ lintVerbose: false,+ } as never,+ async () => lintResult,+ );+ const summaryOutput = logSpy.mock.calls.map((c) => c[0]).join("\n");+ expect(summaryOutput).toContain("1 warning(s)");+ expect(summaryOutput).not.toContain("some_warning");++ logSpy.mockClear();+ await runRenderLint(+ {+ project: { dir: "/tmp/project" },+ entryFile: undefined,+ renderTarget: "/tmp/project/index.html",+ strictErrors: false,+ strictAll: false,+ effectiveQuiet: false,+ lintVerbose: true,+ } as never,+ async () => lintResult,+ );+ const verboseOutput = logSpy.mock.calls.map((c) => c[0]).join("\n");+ expect(verboseOutput).toContain("some_warning");++ logSpy.mockRestore();+ });+function setEnv(key: string, value: string) {if (!savedEnv.has(key)) savedEnv.set(key, process.env[key]);process.env[key] = value;diff --git a/packages/cli/src/commands/render.ts b/packages/cli/src/commands/render.tsindex a4e32f5fc3..0383c43641 100644--- a/packages/cli/src/commands/render.ts+++ b/packages/cli/src/commands/render.ts@@ -35,6 +35,10 @@ export const examples: Example[] = [["Deterministic render via Docker", "hyperframes render --docker --output deterministic.mp4"],["Parallel rendering with 6 workers", "hyperframes render --workers 6 --output fast.mp4"],["Opt out of browser GPU render", "hyperframes render --no-browser-gpu --output cpu.mp4"],+ [+ "Show full lint findings instead of the summary line",+ "hyperframes render --lint-verbose --output out.mp4",+ ],["Relocate frame cache off C: (Windows) or another small partition","hyperframes render --frames-cache-dir D:/hf-cache --output out.mp4",@@ -243,6 +247,11 @@ export default defineCommand({description: "Suppress verbose output",default: false,},+ "lint-verbose": {+ type: "boolean",+ description: "Show full lint findings instead of the summary line",+ default: false,+ },debug: {type: "boolean",description:diff --git a/packages/cli/src/commands/render/execute.ts b/packages/cli/src/commands/render/execute.tsindex eb4ac70e9c..ffc1348ca7 100644--- a/packages/cli/src/commands/render/execute.ts+++ b/packages/cli/src/commands/render/execute.ts@@ -3,7 +3,7 @@ import { mkdirSync, readFileSync } from "node:fs";import type { CanvasResolution, OutputResolutionIssueKind } from "@hyperframes/core";import { c } from "../../ui/colors.js";import { errorBox, formatBytes } from "../../ui/format.js";-import { formatLintFindings } from "../../utils/lintFormat.js";+import { formatLintStartupMessage } from "../../utils/lintFormat.js";import {hasDefinitiveEntryMismatch,lintProject,@@ -53,9 +53,10 @@ function renderLintShouldAbort(strictErrors: boolean,strictAll: boolean,lintResult: ProjectLintResult,+ definitiveEntryMismatch: boolean,): boolean {return (- hasDefinitiveEntryMismatch(lintResult) ||+ definitiveEntryMismatch ||shouldBlockRender(strictErrors, strictAll, lintResult.totalErrors, lintResult.totalWarnings));}@@ -218,9 +219,15 @@ export async function runRenderLint(? await runRenderLintInOwnedProcess(plan.project.dir, explicitEntry, signal): await runLint(plan.project.dir, explicitEntry);if (lintResult.totalErrors === 0 && lintResult.totalWarnings === 0) return;- presentRenderLintFindings(lintResult, plan.effectiveQuiet);const definitiveEntryMismatch = hasDefinitiveEntryMismatch(lintResult);- if (renderLintShouldAbort(plan.strictErrors, plan.strictAll, lintResult)) {+ const willAbort = renderLintShouldAbort(+ plan.strictErrors,+ plan.strictAll,+ lintResult,+ definitiveEntryMismatch,+ );+ presentRenderLintFindings(lintResult, plan.effectiveQuiet, plan.lintVerbose || willAbort);+ if (willAbort) {presentRenderLintAbort(plan, definitiveEntryMismatch);failCommand();}@@ -245,10 +252,15 @@ async function runRenderLintInOwnedProcess(function presentRenderLintFindings(lintResult: Awaited<ReturnType<typeof lintProject>>,quiet: boolean,+ lintVerbose: boolean,): void {if (quiet) return;console.log("");- for (const line of formatLintFindings(lintResult, { errorsFirst: true })) console.log(line);+ for (const line of formatLintStartupMessage(+ lintResult,+ lintVerbose ? { kind: "verbose", options: { errorsFirst: true } } : { kind: "summary" },+ ))+ console.log(line);}function presentRenderLintAbort(plan: RenderPlan, definitiveEntryMismatch: boolean): void {diff --git a/packages/cli/src/commands/render/plan.ts b/packages/cli/src/commands/render/plan.tsindex 509f62574d..23bd6d3bfb 100644--- a/packages/cli/src/commands/render/plan.ts+++ b/packages/cli/src/commands/render/plan.ts@@ -87,6 +87,7 @@ export interface RenderCommandArgs {"best-effort"?: boolean;strict?: boolean;"strict-all"?: boolean;+ "lint-verbose"?: boolean;"max-concurrent-renders"?: string;variables?: string;"variables-file"?: string;@@ -139,6 +140,7 @@ export interface RenderPlan {useGpu: boolean;browserGpuMode: BrowserGpuMode;quiet: boolean;+ lintVerbose: boolean;debug: boolean;bestEffort: boolean;batchJson: boolean;@@ -533,6 +535,7 @@ export function createRenderPlan(args: RenderCommandArgs, now = new Date()): RenuseGpu,browserGpuMode,quiet,+ lintVerbose: args["lint-verbose"] ?? false,debug: args.debug ?? false,bestEffort: args["best-effort"] ?? true,batchJson,diff --git a/packages/cli/src/utils/lintFormat.test.ts b/packages/cli/src/utils/lintFormat.test.tsindex 0becb242b0..c66f5b0d56 100644--- a/packages/cli/src/utils/lintFormat.test.ts+++ b/packages/cli/src/utils/lintFormat.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";import type { HyperframeLintFinding } from "@hyperframes/core/lint";-import { formatLintFindings } from "./lintFormat.js";+import { formatLintFindings, formatLintStartupMessage } from "./lintFormat.js";import type { ProjectLintResult } from "./lintProject.js";function finding(@@ -205,3 +205,37 @@ describe("formatLintFindings", () => {expect(verbose.at(-1)).toContain("1 error(s), 0 warning(s), 1 info(s)");});});++describe("formatLintStartupMessage", () => {+ const result = project([+ {+ file: "index.html",+ findings: [finding("error"), finding("error"), finding("warning")],+ },+ ]);++ it("collapses to a one-line summary by default, pointing at --lint-verbose (no Studio open)", () => {+ const lines = formatLintStartupMessage(result, { kind: "summary" });+ expect(lines).toHaveLength(1);+ expect(lines[0]).toContain("2 error(s), 1 warning(s)");+ expect(lines[0]).not.toContain("Studio");+ expect(lines[0]).toContain("--lint-verbose");+ });++ it("names the Studio badge and the lint command when pointer is 'studio'", () => {+ const lines = formatLintStartupMessage(result, { kind: "summary", pointer: "studio" });+ expect(lines[0]).toContain("Lint badge in Studio");+ expect(lines[0]).toContain("hyperframes lint");+ });++ it("does not print individual findings in the default summary", () => {+ const lines = formatLintStartupMessage(result, { kind: "summary" });+ expect(lines.join("\n")).not.toContain("error-code");+ });++ it("prints full per-finding output when verbose", () => {+ const lines = formatLintStartupMessage(result, { kind: "verbose" });+ expect(lines).toEqual(formatLintFindings(result));+ expect(lines.length).toBeGreaterThan(1);+ });+});diff --git a/packages/cli/src/utils/lintFormat.ts b/packages/cli/src/utils/lintFormat.tsindex 168fbdcac6..8da13a8ae8 100644--- a/packages/cli/src/utils/lintFormat.ts+++ b/packages/cli/src/utils/lintFormat.ts@@ -58,10 +58,39 @@ export function formatLintFindings(if (showSummary) {const icon = totalErrors > 0 ? c.error("◇") : c.success("◇");lines.push("");- const summaryParts = [`${totalErrors} error(s)`, `${totalWarnings} warning(s)`];- if (verbose && totalInfos > 0) summaryParts.push(`${totalInfos} info(s)`);- lines.push(`${icon} ${summaryParts.join(", ")}`);+ lines.push(`${icon} ${formatLintCounts(totalErrors, totalWarnings, totalInfos, verbose)}`);}return lines;}++function formatLintCounts(+ totalErrors: number,+ totalWarnings: number,+ totalInfos: number,+ verbose: boolean,+): string {+ const parts = [`${totalErrors} error(s)`, `${totalWarnings} warning(s)`];+ if (verbose && totalInfos > 0) parts.push(`${totalInfos} info(s)`);+ return parts.join(", ");+}++/** Full findings in verbose mode, a one-line summary otherwise. `pointer` (summary+ * mode) picks the hint: "cli" names --lint-verbose, "studio" also names the lint+ * command, since preview's stdout may be read by an agent. */+export type LintMessageMode =+ | { kind: "verbose"; options?: LintFormatOptions }+ | { kind: "summary"; pointer?: "cli" | "studio" };++export function formatLintStartupMessage(+ lintResult: ProjectLintResult,+ mode: LintMessageMode,+): string[] {+ if (mode.kind === "verbose") return formatLintFindings(lintResult, mode.options);+ const counts = formatLintCounts(lintResult.totalErrors, lintResult.totalWarnings, 0, false);+ const hint =+ mode.pointer === "studio"+ ? "see the Lint badge in Studio, or run `hyperframes lint` for full output"+ : "run with --lint-verbose for full output";+ return [` Lint: ${counts} — ${hint}.`];+}