Skip to content

Write HTML. Render video. Built for agents.

fix(cli,studio): surface project lint in Studio (#3393)

Miguel Ángel8b67bb6db591
diff --git a/packages/cli/src/commands/publish.test.ts b/packages/cli/src/commands/publish.test.ts
index a918935102..3f3334836a 100644
--- a/packages/cli/src/commands/publish.test.ts
+++ b/packages/cli/src/commands/publish.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from "vitest";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
-import { join } from "node:path";
+import { dirname, join } from "node:path";
import { tmpdir } from "node:os";
const publishState = vi.hoisted(() => ({ publish: vi.fn() }));
@@ -37,16 +37,16 @@ describe("parseUpdateTarget", () => {
});
describe("publish default-entry preflight", () => {
- it("rejects the real fixture before creating or uploading an archive", async () => {
+ async function runEntryMismatch(candidate: string): Promise<string> {
const project = mkdtempSync(join(tmpdir(), "hf-publish-entry-mismatch-"));
- const compositions = join(project, "compositions");
- mkdirSync(compositions);
+ const candidatePath = join(project, candidate);
+ mkdirSync(dirname(candidatePath), { recursive: true });
writeFileSync(
join(project, "index.html"),
`<html><body><div data-composition-id="main" data-width="1920" data-height="1080" data-start="0" data-duration="10"></div></body></html>`,
);
writeFileSync(
- join(compositions, "index.html"),
+ candidatePath,
`<html><body><div data-composition-id="authored" data-width="1920" data-height="1080" data-start="0" data-duration="5"><div class="clip" data-start="0" data-duration="5">Visible</div></div></body></html>`,
);
publishState.publish.mockReset();
@@ -58,14 +58,35 @@ describe("publish default-entry preflight", () => {
url: "https://hyperframes.dev/p/project-id",
claimToken: "",
});
+ const lines: string[] = [];
+ const log = vi.spyOn(console, "log").mockImplementation((...parts: unknown[]) => {
+ lines.push(parts.map(String).join(" "));
+ });
try {
await expect(
publishCommand.run?.({ args: { dir: project, yes: true, proxy: false } } as never),
).rejects.toMatchObject({ name: "CliRuntimeError" });
expect(publishState.publish).not.toHaveBeenCalled();
+ return lines.join("\n");
} finally {
+ log.mockRestore();
rmSync(project, { recursive: true, force: true });
}
+ }
+
+ it("suggests a nested index.html directory with the re-rooting caveat", async () => {
+ const output = await runEntryMismatch("compositions/brand/index.html");
+
+ expect(output).toContain("hyperframes publish <project>/compositions/brand");
+ expect(output).toContain("assets are self-contained under that directory");
+ });
+
+ it("does not suggest a directory for a standalone file that is not index.html", async () => {
+ const output = await runEntryMismatch("compositions/card.html");
+
+ expect(output).toContain("compositions/card.html");
+ expect(output).not.toContain("hyperframes publish <project>/compositions");
+ expect(output).toContain("publish accepts project directories, not individual HTML files");
});
});
diff --git a/packages/cli/src/commands/publish.ts b/packages/cli/src/commands/publish.ts
index 115bb6807f..1959e17662 100644
--- a/packages/cli/src/commands/publish.ts
+++ b/packages/cli/src/commands/publish.ts
@@ -1,4 +1,4 @@
-import { join, relative, resolve } from "node:path";
+import { join, posix, relative, resolve } from "node:path";
import { failCommand, setCommandExitCode } from "../utils/commandResult.js";
import { existsSync } from "node:fs";
import { defineCommand } from "citty";
@@ -6,7 +6,11 @@ import * as clack from "@clack/prompts";
import type { Example } from "./_examples.js";
import { c } from "../ui/colors.js";
-import { hasDefinitiveEntryMismatch, lintProject } from "../utils/lintProject.js";
+import {
+ definitiveEntryMismatchComposition,
+ hasDefinitiveEntryMismatch,
+ lintProject,
+} from "../utils/lintProject.js";
import { formatLintFindings } from "../utils/lintFormat.js";
import {
buildPublishFileMap,
@@ -93,7 +97,23 @@ export default defineCommand({
console.log();
}
if (hasDefinitiveEntryMismatch(lintResult)) {
+ 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") {
+ const candidateDir = posix.dirname(candidate);
+ const target = `<project>/${candidateDir}`;
+ console.log(
+ c.dim(
+ ` Move or mount the authored file, or publish its directory directly: hyperframes publish ${target}. Only use the directory form when its assets are self-contained under that directory; otherwise mount it from the project root.`,
+ ),
+ );
+ } else if (candidate) {
+ console.log(
+ c.dim(
+ ` Move or mount ${candidate} as a project index.html before publishing; publish accepts project directories, not individual HTML files.`,
+ ),
+ );
+ }
console.log();
failCommand();
}
diff --git a/packages/cli/src/commands/snapshot.test.ts b/packages/cli/src/commands/snapshot.test.ts
index 4cd4a7032d..20ac38e668 100644
--- a/packages/cli/src/commands/snapshot.test.ts
+++ b/packages/cli/src/commands/snapshot.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from "vitest";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
-import { join } from "node:path";
+import { dirname, join } from "node:path";
import { tmpdir } from "node:os";
const snapshotState = vi.hoisted(() => ({
@@ -85,16 +85,16 @@ describe("transparent snapshot capture", () => {
});
describe("snapshot lint preflight", () => {
- it("rejects the real fixture before invoking browser capture", async () => {
+ async function runEntryMismatch(candidate: string): Promise<string> {
const project = mkdtempSync(join(tmpdir(), "hf-snapshot-entry-mismatch-"));
- const compositions = join(project, "compositions");
- mkdirSync(compositions);
+ const candidatePath = join(project, candidate);
+ mkdirSync(dirname(candidatePath), { recursive: true });
writeFileSync(
join(project, "index.html"),
`<html><body><div data-composition-id="main" data-width="1920" data-height="1080" data-start="0" data-duration="10"></div></body></html>`,
);
writeFileSync(
- join(compositions, "index.html"),
+ candidatePath,
`<html><body><div data-composition-id="authored" data-width="1920" data-height="1080" data-start="0" data-duration="5"><div class="clip" data-start="0" data-duration="5">Visible</div></div></body></html>`,
);
snapshotState.openSettledPage.mockClear();
@@ -110,12 +110,26 @@ describe("snapshot lint preflight", () => {
name: "CliRuntimeError",
});
expect(snapshotState.openSettledPage).not.toHaveBeenCalled();
- expect(lines.join("\n")).toContain("hyperframes snapshot");
- expect(lines.join("\n")).toContain("compositions");
+ return lines.join("\n");
} finally {
log.mockRestore();
rmSync(project, { recursive: true, force: true });
}
+ }
+
+ it("does not suggest a directory for a standalone file that is not index.html", async () => {
+ const output = await runEntryMismatch("compositions/card.html");
+
+ expect(output).toContain("compositions/card.html");
+ expect(output).not.toContain("hyperframes snapshot <project>/compositions");
+ expect(output).toContain("snapshot accepts project directories, not individual HTML files");
+ });
+
+ it("suggests the reported index.html directory with the re-rooting caveat", async () => {
+ const output = await runEntryMismatch("compositions/index.html");
+
+ expect(output).toContain("hyperframes snapshot <project>/compositions");
+ expect(output).toContain("assets are self-contained under that directory");
});
});
diff --git a/packages/cli/src/commands/snapshot.ts b/packages/cli/src/commands/snapshot.ts
index 775d25ba60..aead7e98ef 100644
--- a/packages/cli/src/commands/snapshot.ts
+++ b/packages/cli/src/commands/snapshot.ts
@@ -3,7 +3,7 @@ import { failCommand } from "../utils/commandResult.js";
import { defineCommand } from "citty";
import { existsSync, mkdtempSync, readFileSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
-import { resolve, join, relative, isAbsolute, basename } from "node:path";
+import { resolve, join, relative, isAbsolute, basename, posix } from "node:path";
import {
DEFAULT_ZOOM_SCALE,
captureRegionCrop,
@@ -15,7 +15,11 @@ import {
type ZoomTarget,
} from "../capture/captureCompositionFrame.js";
import { resolveProject } from "../utils/project.js";
-import { hasDefinitiveEntryMismatch, lintProject } from "../utils/lintProject.js";
+import {
+ definitiveEntryMismatchComposition,
+ hasDefinitiveEntryMismatch,
+ lintProject,
+} from "../utils/lintProject.js";
import { formatLintFindings } from "../utils/lintFormat.js";
import { normalizeErrorMessage } from "../utils/errorMessage.js";
import { serveStaticProjectHtml } from "../utils/staticProjectServer.js";
@@ -654,17 +658,28 @@ export default defineCommand({
const project = resolveProject(args.dir);
const lintResult = await lintProject(project.dir);
if (hasDefinitiveEntryMismatch(lintResult)) {
+ const candidate = definitiveEntryMismatchComposition(lintResult);
console.log("");
for (const line of formatLintFindings(lintResult, { errorsFirst: true })) {
console.log(line);
}
console.log("");
console.log(c.error(" Aborting snapshot because the default index.html entry is blank."));
- console.log(
- c.dim(
- " Move or mount the authored file, or snapshot its directory directly: hyperframes snapshot <project>/compositions",
- ),
- );
+ if (candidate && posix.basename(candidate) === "index.html") {
+ const candidateDir = posix.dirname(candidate);
+ const target = `<project>/${candidateDir}`;
+ console.log(
+ c.dim(
+ ` Move or mount the authored file, or snapshot its directory directly: hyperframes snapshot ${target}. Only use the directory form when its assets are self-contained under that directory; otherwise mount it from the project root.`,
+ ),
+ );
+ } else if (candidate) {
+ console.log(
+ c.dim(
+ ` Move or mount ${candidate} as a project index.html before snapshotting; snapshot accepts project directories, not individual HTML files.`,
+ ),
+ );
+ }
console.log("");
failCommand();
}
diff --git a/packages/cli/src/server/studioServer.test.ts b/packages/cli/src/server/studioServer.test.ts
index 9a18a9f334..f7d1973f8e 100644
--- a/packages/cli/src/server/studioServer.test.ts
+++ b/packages/cli/src/server/studioServer.test.ts
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it } from "vitest";
-import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { loadHyperframeRuntimeSource } from "@hyperframes/core";
@@ -84,6 +84,36 @@ describe("createStudioServer autoProxy plumbing", () => {
});
});
+describe("Studio project lint endpoint", () => {
+ it("surfaces findings that require the complete project graph", async () => {
+ const projectDir = tmpProject();
+ mkdirSync(join(projectDir, "compositions"));
+ mkdirSync(join(projectDir, "scenes"));
+ writeFileSync(
+ join(projectDir, "index.html"),
+ `<html><body><div data-composition-id="main" data-width="1920" data-height="1080" data-start="0" data-duration="10"></div></body></html>`,
+ );
+ writeFileSync(
+ join(projectDir, "compositions", "index.html"),
+ `<html><body><div data-composition-id="authored" data-width="1920" data-height="1080" data-start="0" data-duration="5"><div class="clip" data-start="0" data-duration="5">Visible</div></div></body></html>`,
+ );
+ writeFileSync(join(projectDir, "scenes", "intro.html"), "<html><body>Intro</body></html>");
+ server = createStudioServer({ projectDir, projectName: "demo" });
+
+ const response = await server.app.request("http://localhost/api/projects/demo/lint");
+ const payload = (await response.json()) as {
+ findings?: Array<{ code?: string; file?: string }>;
+ };
+
+ expect(response.status).toBe(200);
+ expect(payload.findings).toContainEqual(
+ expect.objectContaining({ code: "blank_root_with_standalone_composition" }),
+ );
+ expect(payload.findings).toContainEqual(expect.objectContaining({ file: "scenes/intro.html" }));
+ expect(payload.findings?.every((finding) => !finding.file?.startsWith(projectDir))).toBe(true);
+ });
+});
+
describe("host guarding on identity-bearing responses", () => {
// NOTE: the SPA-injection branch itself is covered in telemetryIdentity.test.ts
// via buildStudioHeadScriptsForHost. It cannot be asserted here: this route
diff --git a/packages/cli/src/server/studioServer.ts b/packages/cli/src/server/studioServer.ts
index fd37e88ca8..10b455bf88 100644
--- a/packages/cli/src/server/studioServer.ts
+++ b/packages/cli/src/server/studioServer.ts
@@ -431,6 +431,11 @@ export function createStudioServer(options: StudioServerOptions): StudioServer {
return await lintHyperframeHtml(html, opts);
},
+ async lintProject(dir: string) {
+ const { lintProject } = await import("@hyperframes/lint");
+ return await lintProject(dir);
+ },
+
runtimeUrl: "/api/runtime.js",
rendersDir: () => join(projectDir, "renders"),
diff --git a/packages/cli/src/utils/lintProject.ts b/packages/cli/src/utils/lintProject.ts
index 5a6f4897d5..04e1cccd95 100644
--- a/packages/cli/src/utils/lintProject.ts
+++ b/packages/cli/src/utils/lintProject.ts
@@ -11,3 +11,13 @@ export function hasDefinitiveEntryMismatch(result: ProjectLintResult): boolean {
),
);
}
+
+export function definitiveEntryMismatchComposition(result: ProjectLintResult): string | undefined {
+ for (const entry of result.results) {
+ const finding = entry.result.findings.find(
+ (candidate) => candidate.code === "blank_root_with_standalone_composition",
+ );
+ if (finding) return finding.suggestedComposition;
+ }
+ return undefined;
+}
diff --git a/packages/lint/src/project.test.ts b/packages/lint/src/project.test.ts
index 2d35fa5d52..dbcae844bd 100644
--- a/packages/lint/src/project.test.ts
+++ b/packages/lint/src/project.test.ts
@@ -89,7 +89,9 @@ describe("blank_root_with_standalone_composition", () => {
expect(finding?.severity).toBe("error");
expect(finding?.message).toContain("compositions/index.html");
expect(finding?.message).toContain("index.html");
+ expect(finding?.message).toContain("publish");
expect(finding?.fixHint).toContain("data-composition-src");
+ expect(finding?.suggestedComposition).toBe("compositions/index.html");
});
it("treats non-rendering script, style, link, meta, and template children as blank", async () => {
@@ -173,6 +175,24 @@ describe("blank_root_with_standalone_composition", () => {
expect(finding).toBeDefined();
});
+
+ it("does not treat a composition that only mounts another composition as standalone", async () => {
+ const project = makeProject(validHtml(), {
+ "wrapper.html": `<!doctype html><html><body>
+ <div data-composition-id="wrapper" data-width="1920" data-height="1080" data-start="0" data-duration="5">
+ <div data-composition-src="compositions/scene.html" data-start="0" data-duration="5"></div>
+ </div>
+</body></html>`,
+ "scene.html": `<template><div data-composition-id="scene"><p>Scene</p></div></template>`,
+ });
+
+ const { results } = await lintProject(project);
+ const finding = results
+ .flatMap((result) => result.result.findings)
+ .find((item) => item.code === "blank_root_with_standalone_composition");
+
+ expect(finding).toBeUndefined();
+ });
});
describe("missing_or_empty_sub_composition", () => {
diff --git a/packages/lint/src/project.ts b/packages/lint/src/project.ts
index a4f522488e..a9b2999417 100644
--- a/packages/lint/src/project.ts
+++ b/packages/lint/src/project.ts
@@ -287,10 +287,11 @@ function lintBlankRootWithStandaloneComposition(
{
code: "blank_root_with_standalone_composition",
severity: "error",
- message: `The default index.html composition has no renderable content, but ${standaloneCandidates.join(", ")} contains a standalone timed composition. Default check, snapshot, preview, and render commands open index.html, so they will capture only its background.`,
+ message: `The default index.html composition has no renderable content, but ${standaloneCandidates.join(", ")} contains a standalone timed composition. Default check, snapshot, preview, render, and publish commands open index.html, so they will capture or publish only its background.`,
fixHint:
`Move the authored composition into index.html, or mount it from index.html with data-composition-src and the sub-composition <template> contract. ` +
`If the separate file is intentional, render it explicitly with --composition ${standaloneCandidates[0]}.`,
+ suggestedComposition: standaloneCandidates[0],
},
];
}
diff --git a/packages/lint/src/types.ts b/packages/lint/src/types.ts
index 67f0985fe7..3b92152d0f 100644
--- a/packages/lint/src/types.ts
+++ b/packages/lint/src/types.ts
@@ -9,6 +9,8 @@ export type HyperframeLintFinding = {
elementId?: string;
fixHint?: string;
snippet?: string;
+ /** Optional standalone entry that command-specific guidance can act on. */
+ suggestedComposition?: string;
};
/**
diff --git a/packages/studio-server/src/routes/lint.test.ts b/packages/studio-server/src/routes/lint.test.ts
index 7783fc3c41..500ca57e5e 100644
--- a/packages/studio-server/src/routes/lint.test.ts
+++ b/packages/studio-server/src/routes/lint.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, describe, expect, it } from "vitest";
+import { afterEach, describe, expect, it, vi } from "vitest";
import { Hono } from "hono";
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -58,4 +58,92 @@ describe("registerLintRoutes — dot-directory exclusion (#1384)", () => {
expect(lintedFiles).toContain("index.html");
expect(lintedFiles).not.toContain(".hyperframes/preset.html");
});
+
+ it("returns project-level findings instead of re-linting files independently", async () => {
+ const projectDir = createProjectDir();
+ const singleFileLint = vi.fn(async () => ({ findings: [] }));
+ const projectLint = vi.fn(async () => ({
+ results: [
+ {
+ file: "index.html",
+ result: {
+ findings: [
+ {
+ code: "blank_root_with_standalone_composition",
+ severity: "error",
+ message: "The default entry is blank.",
+ file: join(projectDir, "index.html"),
+ },
+ ],
+ },
+ },
+ ],
+ }));
+ const adapter = {
+ ...createAdapter(projectDir),
+ lint: singleFileLint,
+ lintProject: projectLint,
+ };
+ const app = new Hono();
+ registerLintRoutes(app, adapter);
+
+ const response = await app.request("http://localhost/projects/demo/lint");
+ const payload = (await response.json()) as {
+ findings?: Array<{ code?: string; file?: string }>;
+ };
+
+ expect(response.status).toBe(200);
+ expect(projectLint).toHaveBeenCalledWith(projectDir);
+ expect(singleFileLint).not.toHaveBeenCalled();
+ expect(payload.findings).toContainEqual(
+ expect.objectContaining({
+ code: "blank_root_with_standalone_composition",
+ file: "index.html",
+ }),
+ );
+ });
+
+ it("unions project lint with HTML files outside the canonical project graph", async () => {
+ const projectDir = createProjectDir();
+ const scenesDir = join(projectDir, "scenes");
+ mkdirSync(scenesDir);
+ writeFileSync(join(scenesDir, "intro.html"), "<html><body>intro</body></html>");
+ const singleFileLint = vi.fn(async () => ({
+ findings: [
+ {
+ code: "scene_finding",
+ severity: "warning",
+ message: "Scene finding.",
+ file: join(projectDir, "scenes", "intro.html"),
+ },
+ ],
+ }));
+ const projectLint = vi.fn(async () => ({
+ results: [
+ {
+ file: "index.html",
+ result: { findings: [] },
+ },
+ ],
+ }));
+ const app = new Hono();
+ registerLintRoutes(app, {
+ ...createAdapter(projectDir),
+ lint: singleFileLint,
+ lintProject: projectLint,
+ });
+
+ const response = await app.request("http://localhost/projects/demo/lint");
+ const payload = (await response.json()) as {
+ findings?: Array<{ code?: string; file?: string }>;
+ };
+
+ expect(singleFileLint).toHaveBeenCalledTimes(1);
+ expect(singleFileLint).toHaveBeenCalledWith("<html><body>intro</body></html>", {
+ filePath: "scenes/intro.html",
+ });
+ expect(payload.findings).toContainEqual(
+ expect.objectContaining({ code: "scene_finding", file: "scenes/intro.html" }),
+ );
+ });
});
diff --git a/packages/studio-server/src/routes/lint.ts b/packages/studio-server/src/routes/lint.ts
index 5a1b48b97d..deaad93ed3 100644
--- a/packages/studio-server/src/routes/lint.ts
+++ b/packages/studio-server/src/routes/lint.ts
@@ -1,9 +1,47 @@
import type { Hono } from "hono";
import { readFileSync } from "node:fs";
import { join } from "node:path";
-import type { StudioApiAdapter } from "../types.js";
+import type { LintResult, StudioApiAdapter } from "../types.js";
import { isInHiddenOrVendorDir, walkDir } from "../helpers/safePath.js";
+type LintFinding = LintResult["findings"][number];
+
+async function collectProjectFindings(
+ adapter: StudioApiAdapter,
+ projectDir: string,
+): Promise<{ findings: LintFinding[]; coveredFiles: Set<string> }> {
+ const findings: LintFinding[] = [];
+ const coveredFiles = new Set<string>();
+ if (!adapter.lintProject) return { findings, coveredFiles };
+
+ const result = await adapter.lintProject(projectDir);
+ for (const entry of result.results) {
+ coveredFiles.add(entry.file);
+ for (const finding of entry.result.findings) {
+ findings.push({ ...finding, file: entry.file });
+ }
+ }
+ return { findings, coveredFiles };
+}
+
+async function lintUncoveredHtml(
+ adapter: StudioApiAdapter,
+ projectDir: string,
+ htmlFiles: string[],
+ coveredFiles: Set<string>,
+): Promise<LintFinding[]> {
+ const findings: LintFinding[] = [];
+ for (const file of htmlFiles) {
+ if (coveredFiles.has(file)) continue;
+ const content = readFileSync(join(projectDir, file), "utf-8");
+ const result = await adapter.lint(content, { filePath: file });
+ for (const finding of result?.findings ?? []) {
+ findings.push({ ...finding, file });
+ }
+ }
+ return findings;
+}
+
export function registerLintRoutes(api: Hono, adapter: StudioApiAdapter): void {
api.get("/projects/:id/lint", async (c) => {
const project = await adapter.resolveProject(c.req.param("id"));
@@ -12,22 +50,14 @@ export function registerLintRoutes(api: Hono, adapter: StudioApiAdapter): void {
const htmlFiles = walkDir(project.dir).filter(
(f) => f.endsWith(".html") && !isInHiddenOrVendorDir(f),
);
- const allFindings: Array<{
- severity: string;
- message: string;
- file?: string;
- fixHint?: string;
- }> = [];
- for (const file of htmlFiles) {
- const content = readFileSync(join(project.dir, file), "utf-8");
- const result = await adapter.lint(content, { filePath: file });
- if (result?.findings) {
- for (const f of result.findings) {
- allFindings.push({ ...f, file });
- }
- }
- }
- return c.json({ findings: allFindings });
+ const projectLint = await collectProjectFindings(adapter, project.dir);
+ const extraFindings = await lintUncoveredHtml(
+ adapter,
+ project.dir,
+ htmlFiles,
+ projectLint.coveredFiles,
+ );
+ return c.json({ findings: [...projectLint.findings, ...extraFindings] });
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
return c.json({ error: `Lint failed: ${msg}` }, 500);
diff --git a/packages/studio-server/src/types.ts b/packages/studio-server/src/types.ts
index b569f45ace..1344b90701 100644
--- a/packages/studio-server/src/types.ts
+++ b/packages/studio-server/src/types.ts
@@ -45,6 +45,7 @@ export interface MediaProcessingJobState {
/** Lint result from the core linter. */
export interface LintResult {
findings: Array<{
+ code?: string;
severity: string;
message: string;
file?: string;
@@ -52,6 +53,10 @@ export interface LintResult {
}>;
}
+export interface ProjectLintResult {
+ results: Array<{ file: string; result: LintResult }>;
+}
+
export interface StudioSelectionTextField {
key: string;
label: string;
@@ -110,6 +115,13 @@ export interface StudioApiAdapter {
/** Lint a single HTML string. */
lint(html: string, opts?: { filePath?: string }): Promise<LintResult> | LintResult;
+ /**
+ * Lint the complete project, including relationships between files. Official
+ * adapters provide this; the single-file method remains as a compatibility
+ * fallback for third-party adapters compiled against older releases.
+ */
+ lintProject?: (projectDir: string) => Promise<ProjectLintResult> | ProjectLintResult;
+
/** URL to the hyperframe runtime JS (injected into preview HTML). */
runtimeUrl: string;
diff --git a/packages/studio/vite.adapter.ts b/packages/studio/vite.adapter.ts
index 6bad725b75..148dfbcaa3 100644
--- a/packages/studio/vite.adapter.ts
+++ b/packages/studio/vite.adapter.ts
@@ -210,6 +210,11 @@ export function createViteAdapter(dataDir: string, server: ViteDevServer): Studi
return await mod.lintHyperframeHtml(html, opts);
},
+ async lintProject(projectDir: string) {
+ const mod = await server.ssrLoadModule("@hyperframes/core/lint");
+ return await mod.lintProject(projectDir);
+ },
+
runtimeUrl: "/api/runtime.js",
rendersDir: () => resolve(dataDir, "../renders"),