diff --git a/packages/cli/src/capture/contentExtractor.ts b/packages/cli/src/capture/contentExtractor.ts index dfd0cee48d..fc08eafd85 100644 --- a/packages/cli/src/capture/contentExtractor.ts +++ b/packages/cli/src/capture/contentExtractor.ts @@ -363,13 +363,28 @@ export function generateAssetDescriptions( const heading = catalogMatch?.nearestHeading || ""; const section = catalogMatch?.sectionClasses || ""; const aboveFold = catalogMatch?.aboveFold ? "above fold" : ""; + // Logo signals — let the no-Gemini fallback still surface logos + // grep-ably even when Vision wasn't available to describe them. + const isLikelyLogo = !!( + catalogMatch?.inBanner || + catalogMatch?.inHomeLink || + catalogMatch?.matchesTitleBrand || + /logo|brand|wordmark/i.test(desc) || + /logo|brand|wordmark/i.test(section) || + file.includes("logo") + ); const geminiCaption = geminiCaptions[file]; const cleanName = file.replace(/\.[^.]+$/, "").replace(/[-_]/g, " "); const parts = [`${file} — ${sizeKb}KB`]; if (geminiCaption) { + // Even with Gemini's description, prepend the LOGO tag if + // structural signals fired — gives a stable grep target for + // agents searching for "the logo." + if (isLikelyLogo) parts.push("LOGO"); parts.push(geminiCaption); captionedLines.push(parts.join(", ")); } else { + if (isLikelyLogo) parts.push("LOGO"); if (desc) parts.push(`"${desc.slice(0, 80)}"`); if (heading) parts.push(`section: "${heading.slice(0, 60)}"`); else if (section) parts.push(`in: ${section.split(" ").slice(0, 3).join(" ")}`); @@ -403,8 +418,16 @@ export function generateAssetDescriptions( ), ); const label = svgMatch?.label || file.replace(".svg", "").replace(/-/g, " "); - const isLogo = svgMatch?.isLogo || file.includes("logo"); - svgLines.push(`svgs/${file} — ${isLogo ? "logo: " : "icon: "}${label}`); + // Filename prefix is now the most reliable logo signal: the + // capture pipeline names DOM-marked logos `logo-.svg` and + // everything else `svg-.svg`. Fall back to the tokens.svgs + // isLogo flag for legacy captures + a filename-includes-"logo" + // check for human-readable rasters. + const isLogo = file.startsWith("logo-") || svgMatch?.isLogo || file.includes("logo"); + // Use uppercase "LOGO:" so agents can grep for it as a single, + // unambiguous token. The lowercase "logo:" prefix was easy to miss + // since real Vision captions also use the word casually. + svgLines.push(`svgs/${file} — ${isLogo ? "LOGO: " : "icon: "}${label}`); } } catch { /* no svgs dir */ diff --git a/packages/cli/src/capture/index.ts b/packages/cli/src/capture/index.ts index 89121c0ead..e16c947ec8 100644 --- a/packages/cli/src/capture/index.ts +++ b/packages/cli/src/capture/index.ts @@ -522,14 +522,19 @@ export async function captureWebsite( const lines = generateAssetDescriptions(outputDir, tokens, catalogedAssets, geminiCaptions); if (lines.length > 0) { + const hasGeminiKey = !!(process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY); + const header = hasGeminiKey + ? "# Asset Descriptions\n\nOne line per file. Read this instead of opening every image individually. Lines tagged `LOGO` are the brand-mark candidates — search for the brand name here BEFORE composing a logo from scratch.\n\n" + : "# Asset Descriptions\n\n⚠️ GEMINI_API_KEY not set — descriptions below are catalog-derived (alt text, headings, section context, filename) instead of Vision-generated. Lines tagged `LOGO` are the brand-mark candidates per DOM-structural signals (inside header/nav, inside home anchor, or alt-text matching the page title). To get richer Vision descriptions on the next capture, set GEMINI_API_KEY (or GOOGLE_API_KEY) and re-run.\n\nWhen the description is too weak to identify a captured logo by description alone, open the LOGO-tagged SVGs in a previewer or `sharp`-render them to PNG before referencing — the alternative (composing a fake logo) ships off-brand in the final video.\n\n"; writeFileSync( join(outputDir, "extracted", "asset-descriptions.md"), - "# Asset Descriptions\n\nOne line per file. Read this instead of opening every image individually.\n\n" + - lines.map((l) => "- " + l).join("\n") + - "\n", + header + lines.map((l) => "- " + l).join("\n") + "\n", "utf-8", ); - progress("design", `${lines.length} asset descriptions written`); + progress( + "design", + `${lines.length} asset descriptions written${hasGeminiKey ? "" : " (no Gemini key — catalog-fallback mode)"}`, + ); } } catch { /* non-critical */