Skip to content

Commit 952e922

Browse files
fix(cli): bound capture runs and degrade WebGL navigation (#4215)
* fix(cli): bound capture runs and degrade WebGL navigation * fix(cli): keep partial capture on deadline * fix(cli): persist partial capture artifacts * fix(cli): reduce capture phase complexity * chore(cli): tighten capture comments * fix(cli): restore post-capture phase calls * fix(cli): parse extracted scripts before filtering * fix(cli): remove next data through dom filter * refactor(cli): move capture attempt into module * refactor(cli): extract capture phases into modules * refactor(cli): split navigation checks * refactor(cli): deduplicate capture phase modules * fix(cli): preserve bounded capture output on deadline * fix(cli): secure capture artifact writes * fix(cli): close remaining capture file alerts * fix(cli): mark deadline captures unsuccessful * refactor(cli): centralize capture phase schema * style(cli): format capture watchdog test * docs(cli): condense capture attempt header
1 parent c797f54 commit 952e922

27 files changed

Lines changed: 1884 additions & 938 deletions

‎.fallowrc.jsonc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@
419419
// as a direct dep to guarantee installation even when transitive
420420
// resolution fails (corrupted cache, dedup edge cases).
421421
"debug",
422+
// Loaded through the optional package loader for Gemini vision captioning.
423+
"@google/genai",
422424
"puppeteer",
423425
"puppeteer-core",
424426
"esbuild",

‎packages/cli/src/capture/agentPromptGenerator.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* product-launch-video skill — this file points agents there.
1111
*/
1212

13-
import { writeFileSync, readdirSync, existsSync } from "node:fs";
13+
import { readdirSync, existsSync } from "node:fs";
14+
import { writeCaptureFileSync } from "./captureFile.js";
1415
import { join } from "node:path";
1516
import type { DesignTokens } from "./types.js";
1617
import type { AnimationCatalog } from "./animationCataloger.js";
@@ -52,9 +53,9 @@ export function generateAgentPrompt(
5253
_detectedLibraries?: string[],
5354
): void {
5455
const prompt = buildPrompt(outputDir, url, tokens, hasScreenshot, hasLottie, hasShaders);
55-
writeFileSync(join(outputDir, "AGENTS.md"), prompt, "utf-8");
56-
writeFileSync(join(outputDir, "CLAUDE.md"), prompt, "utf-8");
57-
writeFileSync(join(outputDir, ".cursorrules"), prompt, "utf-8");
56+
writeCaptureFileSync(join(outputDir, "AGENTS.md"), prompt, "utf-8");
57+
writeCaptureFileSync(join(outputDir, "CLAUDE.md"), prompt, "utf-8");
58+
writeCaptureFileSync(join(outputDir, ".cursorrules"), prompt, "utf-8");
5859
}
5960

6061
// fallow-ignore-next-line complexity

‎packages/cli/src/capture/assetDownloader.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
*/
77

88
import { isBlockedNetworkHost } from "@hyperframes/engine";
9-
import { writeFileSync, mkdirSync } from "node:fs";
9+
import { mkdirSync } from "node:fs";
10+
import { writeCaptureFileSync } from "./captureFile.js";
1011
import { join, extname } from "node:path";
1112
import { createHash } from "node:crypto";
1213
import type { DesignTokens, DownloadedAsset } from "./types.js";
@@ -206,7 +207,7 @@ async function fetchAndInspectIcon(
206207
if (!ext) return null;
207208

208209
const file = `assets/${stem}${ext}`;
209-
writeFileSync(join(outputDir, file), buffer);
210+
writeCaptureFileSync(join(outputDir, file), buffer);
210211
const verdict = await classifyIcon(buffer, ext);
211212
return {
212213
buffer,
@@ -235,7 +236,7 @@ function promoteHeadline(
235236
if (!chosen) return null;
236237

237238
const file = `assets/favicon${extname(chosen.file)}`;
238-
writeFileSync(join(outputDir, file), bytesByFile.get(chosen.file)!);
239+
writeCaptureFileSync(join(outputDir, file), bytesByFile.get(chosen.file)!);
239240
manifest.headline = {
240241
file,
241242
source: chosen.file,
@@ -346,7 +347,7 @@ export async function downloadAssets(
346347
const name = `${finalSlug}.svg`;
347348
const localPath = `assets/svgs/${name}`;
348349
try {
349-
writeFileSync(join(outputDir, localPath), svgFile, "utf-8");
350+
writeCaptureFileSync(join(outputDir, localPath), svgFile, "utf-8");
350351
assets.push({ url: "", localPath, type: "svg" });
351352
} catch {
352353
drops.unavailable++;
@@ -472,7 +473,7 @@ export async function downloadAssets(
472473
const name = `${slug}${ext}`;
473474
usedNames.add(slug);
474475
const localPath = `assets/${name}`;
475-
writeFileSync(join(outputDir, localPath), buffer);
476+
writeCaptureFileSync(join(outputDir, localPath), buffer);
476477
assets.push({ url, localPath, type: "image" });
477478
imgIdx++;
478479
} catch {
@@ -501,7 +502,7 @@ export async function downloadAssets(
501502
drops["size-floor"]++;
502503
} else {
503504
const localPath = `assets/og-image${ext}`;
504-
writeFileSync(join(outputDir, localPath), buffer);
505+
writeCaptureFileSync(join(outputDir, localPath), buffer);
505506
assets.push({ url: tokens.ogImage, localPath, type: "image" });
506507
}
507508
}
@@ -614,7 +615,7 @@ export async function downloadAndRewriteFonts(
614615
const filename = captureFontFilename(fontUrl, extension, usedFontNames);
615616
const localPath = join(assetsDir, filename);
616617
const relativePath = `assets/fonts/${filename}`;
617-
writeFileSync(localPath, buffer);
618+
writeCaptureFileSync(localPath, buffer);
618619
rewritten = rewritten.split(fontUrl).join(relativePath);
619620
} else {
620621
drops.unavailable++;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export function captureBrowserArgs(
2+
disableWebgl: boolean,
3+
viewportWidth: number,
4+
viewportHeight: number,
5+
): string[] {
6+
return [
7+
"--no-sandbox",
8+
"--disable-dev-shm-usage",
9+
...(disableWebgl
10+
? ["--disable-gpu"]
11+
: ["--enable-webgl", "--ignore-gpu-blocklist", "--use-gl=angle", "--use-angle=swiftshader"]),
12+
"--disable-blink-features=AutomationControlled",
13+
"--disable-background-timer-throttling",
14+
"--disable-renderer-backgrounding",
15+
`--window-size=${viewportWidth},${viewportHeight}`,
16+
];
17+
}

0 commit comments

Comments
 (0)